loads of changes and added things
[spider.git] / perl / DXMsg.pm
index 9c032ba56f02caf41b682cd87731c6dcbd2c1c0b..9316c374444ca0eff24087994b181f17c1fb7978 100644 (file)
@@ -66,6 +66,7 @@ sub alloc
   $self->{subject} = shift;
   $self->{origin} = shift;
   $self->{read} = shift;
+  $self->{rrreq} = shift;
   $self->{gotit} = [];
     
   return $self;
@@ -131,7 +132,7 @@ sub process
          $ref->{count} = 0;
          $ref->{linesreq} = 5;
          $work{"$f[2]$f[3]"} = $ref;        # new ref
-         dbg('msg', "incoming subject ack stream $[3]\n");
+         dbg('msg', "incoming subject ack stream $f[3]\n");
          $busy{$f[2]} = $ref;                       # interlock
          $ref->{lines} = [];
          push @{$ref->{lines}}, ($ref->read_msg_body);
@@ -166,6 +167,8 @@ sub process
              push @{$ref->{gotit}}, $f[2];           # mark this up as being received
                  $ref->store($ref->{lines});
                  add_dir($ref);
+                 my $dxchan = DXChannel->get($ref->{to});
+                 $dxchan->send("New mail has arrived for you") if $dxchan;
                }
                $ref->stop_msg($self);
                queue_msg();
@@ -591,18 +594,8 @@ sub field_prompt
   return $valid{$ele};
 }
 
-no strict;
-sub AUTOLOAD
-{
-  my $self = shift;
-  my $name = $AUTOLOAD;
-  return if $name =~ /::DESTROY$/;
-  $name =~ s/.*:://o;
-  
-  confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
-  @_ ? $self->{$name} = shift : $self->{$name} ;
-}
-
+#
+# send a message state machine
 sub do_send_stuff
 {
   my $self = shift;
@@ -623,7 +616,7 @@ sub do_send_stuff
        my $loc = $self->{loc};
        if ($line eq "\032" || uc $line eq "/EX") {
       my $to;
-   
+
       if (@{$loc->{lines}} > 0) {
            foreach $to (@{$loc->{to}}) {
              my $ref;
@@ -635,12 +628,15 @@ sub do_send_stuff
                                                        $systime,
                                                        $loc->{private}, 
                                                        $loc->{subject}, 
-                                                       $mycall, 
+                                                       $mycall,
+                                                       '0',
                                                        $loc->{rrreq});
              $ref->store($loc->{lines});
                  $ref->add_dir();
                  #push @out, $self->msg('sendsent', $to);
                  push @out, "msgno $ref->{msgno} sent to $to";
+                 my $dxchan = DXChannel->get(uc $to);
+                 $dxchan->send("New mail has arrived for you") if $dxchan;
            }
          }
          delete $loc->{lines};
@@ -666,6 +662,27 @@ sub do_send_stuff
   return (1, @out);
 }
 
+# return the standard directory line for this ref 
+sub dir
+{
+  my $ref = shift;
+  return sprintf "%6d%s%s%5d %8.8s %8.8s %-6.6s %5.5s %-30.30s", 
+    $ref->msgno, $ref->read ? '-' : ' ', $ref->private ? 'p' : ' ', $ref->size,
+       $ref->to, $ref->from, cldate($ref->t), ztime($ref->t), $ref->subject;
+}
+
+no strict;
+sub AUTOLOAD
+{
+  my $self = shift;
+  my $name = $AUTOLOAD;
+  return if $name =~ /::DESTROY$/;
+  $name =~ s/.*:://o;
+  
+  confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
+  @_ ? $self->{$name} = shift : $self->{$name} ;
+}
+
 1;
 
 __END__