Prepare for git repository
[spider.git] / perl / DXChannel.pm
index adf7c358ddfec793cf90cedf136da8e799355e0e..699e87a8d8da0a4b27008413281cb0be4076af2f 100644 (file)
@@ -101,6 +101,7 @@ $count = 0;
                  itu => '0,ITU Zone',
                  cq => '0,CQ Zone',
                  enhanced => '5,Enhanced Client,yesno',
+                 gtk => '5,Using GTK,yesno',
                  senddbg => '8,Sending Debug,yesno',
                  width => '0,Column Width',
                  disconnecting => '9,Disconnecting,yesno',
@@ -121,12 +122,6 @@ $count = 0;
                  inqueue => '9,Input Queue,parray',
                 );
 
-use vars qw($VERSION $BRANCH);
-$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
-
 # object destruction
 sub DESTROY
 {
@@ -153,7 +148,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;
        }
@@ -357,7 +353,8 @@ sub send_now
         my @lines = split /\n/;
                for (@lines) {
                        $conn->send_now("$sort$call|$_");
-                       dbg("-> $sort $call $_") if isdbg('chan');
+                       # debug log it, but not if it is a log message
+                       dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
                }
        }
        $self->{t} = time;
@@ -380,7 +377,8 @@ sub send_later
         my @lines = split /\n/;
                for (@lines) {
                        $conn->send_later("$sort$call|$_");
-                       dbg("-> $sort $call $_") if isdbg('chan');
+                       # debug log it, but not if it is a log message
+                       dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
                }
        }
        $self->{t} = time;
@@ -396,15 +394,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)
@@ -492,7 +491,9 @@ 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();
@@ -500,7 +501,28 @@ 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)) 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();
+       my $dxchan;
+       foreach $dxchan (@dxchan) {
+               next if $dxchan == $self;
+               next if $dxchan->{call} eq $main::mycall;
+               $dxchan->send($dxchan->msg($m, $call, $node)) if grep $_ eq $call, @{$dxchan->{user}->{buddies}} ;
        }
 }
 
@@ -699,6 +721,19 @@ sub process
        }
 }
 
+sub handle_xml
+{
+       my $self = shift;
+       my $r = 0;
+       
+       if (DXXml::available()) {
+               $r = $self->{handle_xml} || 0;
+       } else {
+               delete $self->{handle_xml} if exists $self->{handle_xml};
+       }
+       return $r;
+}
+
 #no strict;
 sub AUTOLOAD
 {