X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXChannel.pm;h=127f3a0604665e6631784dbc8a871253f72cfb95;hb=0148e301a41d89c154254a457f7d79334eea9442;hp=09290121b88114169eb10045ffd1ab13a4c0cea5;hpb=dce19df96e5dab964cd89cab9c33af470d824109;p=spider.git diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 09290121..127f3a06 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -117,6 +117,7 @@ $count = 0; ve7cc => '0,VE7CC program special,yesno', lastmsgpoll => '0,Last Msg Poll,atime', inscript => '9,In a script,yesno', + handle_xml => '9,Handles XML,yesno', inqueue => '9,Input Queue,parray', ); @@ -152,7 +153,8 @@ sub alloc if (defined $user) { $self->{user} = $user; $self->{lang} = $user->lang; - $user->new_group() if !$user->group; + $user->new_group unless $user->group; + $user->new_buddies unless $user->buddies; $self->{group} = $user->group; $self->{sort} = $user->sort; } @@ -177,6 +179,14 @@ sub alloc return $channels{$call} = $self; } +# rebless this channel as something else +sub rebless +{ + my $self = shift; + my $class = shift; + return $channels{$self->{call}} = bless $self, $class; +} + sub rec { my ($self, $msg) = @_; @@ -387,15 +397,16 @@ sub send # this is always later and always data return unless $conn; my $call = $self->{call}; - for (@_) { -# chomp; - my @lines = split /\n/; - for (@lines) { - $conn->send_later("D$call|$_"); - dbg("-> D $call $_") if isdbg('chan'); + foreach my $l (@_) { + for (ref $l ? @$l : $l) { + my @lines = split /\n/; + for (@lines) { + $conn->send_later("D$call|$_"); + dbg("-> D $call $_") if isdbg('chan'); + } } } - $self->{t} = time; + $self->{t} = $main::systime; } # send a file (always later) @@ -483,7 +494,30 @@ sub closeall # sub tell_login { - my ($self, $m) = @_; + my ($self, $m, $call) = @_; + + $call ||= $self->{call}; + + # send info to all logged in thingies + my @dxchan = get_all_users(); + my $dxchan; + foreach $dxchan (@dxchan) { + next if $dxchan == $self; + next if $dxchan->{call} eq $main::mycall; + $dxchan->send($dxchan->msg($m, $call)) if $dxchan->{logininfo}; + } +} + +# +# Tell all the users if a buddy is logged or out +# +sub tell_buddies +{ + my ($self, $m, $call, $node) = @_; + + $call ||= $self->{call}; + $call =~ s/-\d+$//; + $m .= 'n' if $node; # send info to all logged in thingies my @dxchan = get_all_users(); @@ -491,7 +525,7 @@ sub tell_login foreach $dxchan (@dxchan) { next if $dxchan == $self; next if $dxchan->{call} eq $main::mycall; - $dxchan->send($dxchan->msg($m, $self->{call})) if $dxchan->{logininfo}; + $dxchan->send($dxchan->msg($m, $call, $node)) if grep $_ eq $call, @{$dxchan->{user}->{buddies}} ; } }