2 # DX database control routines
4 # This manages the on-line cluster user 'database'
6 # This should all be pretty trees and things, but for now I
7 # just can't be bothered. If it becomes an issue I shall
10 # Copyright (c) 1998 - Dirk Koopman G1TLH
22 my %cluster = (); # this is where we store the dxcluster database
25 mynode => '0,Parent Node',
27 confmode => '0,Conference Mode,yesno',
28 here => '0,Here?,yesno',
29 dxchan => '5,Channel ref',
30 pcversion => '5,Node Version',
31 list => '5,User List,dolist',
36 my ($pkg, $call, $confmode, $here, $dxchan) = @_;
37 die "$call is already alloced" if $cluster{$call};
39 $self->{call} = $call;
40 $self->{confmode} = $confmode;
41 $self->{here} = $here;
42 $self->{dxchan} = $dxchan;
44 $cluster{$call} = bless $self, $pkg;
48 # search for a call in the cluster
51 my ($pkg, $call) = @_;
52 return $cluster{$call};
58 return values(%cluster);
64 delete $cluster{$self->{call}};
68 # return a prompt for a field
71 my ($self, $ele) = @_;
86 return if $name =~ /::DESTROY$/;
89 die "Non-existant field '$AUTOLOAD'" if !$valid{$name};
90 @_ ? $self->{$name} = shift : $self->{$name} ;
94 # USER special routines
106 my ($pkg, $mynode, $call, $confmode, $here, $dxchan) = @_;
107 my $self = $pkg->alloc($call, $confmode, $here, $dxchan);
108 $self->{mynode} = $mynode;
110 $users{$call} = $self;
117 $self->delcluster(); # out of the whole cluster table
118 delete $users{$self->{call}}; # out of the users table
123 return %users + 1; # + 1 for ME (naf eh!)
129 # NODE special routines
134 @ISA = qw(DXCluster);
141 my ($pkg, $call, $confmode, $here, $pcversion, $dxchan) = @_;
142 my $self = $pkg->alloc($call, $confmode, $here, $dxchan);
143 $self->{version} = $pcversion;
144 $nodes{$call} = $self;
151 my ($pkg, $call) = @_;
152 return $nodes{$call};
160 foreach $list (values(%nodes)) {
161 push @out, $list if $list->{pcversion};
169 my $call = $self->call;
171 DXUser->delete($call); # delete all the users on this node
172 delete $nodes{$call};
177 return %nodes + 1; # + 1 for ME!