]> code.citadel.org Git - citadel.git/commitdiff
Massive re-write. Server is multi-threaded and uses swing.
authorChilly <chilly@uncensored.citadel.org>
Wed, 4 Aug 1999 02:05:51 +0000 (02:05 +0000)
committerChilly <chilly@uncensored.citadel.org>
Wed, 4 Aug 1999 02:05:51 +0000 (02:05 +0000)
31 files changed:
shaggy/CallBack.java [new file with mode: 0644]
shaggy/MsgCmd.java [new file with mode: 0644]
shaggy/NamedPanel.java [deleted file]
shaggy/PairPanel.java
shaggy/Panel3D.java [deleted file]
shaggy/Queue.java [new file with mode: 0644]
shaggy/README
shaggy/STATUS
shaggy/SortedVector.java
shaggy/citGui.java [new file with mode: 0644]
shaggy/citadel.java
shaggy/displayInfo.java [deleted file]
shaggy/enterPanel.java
shaggy/floor.java [new file with mode: 0644]
shaggy/hostPanel.java [new file with mode: 0644]
shaggy/loginPanel.java
shaggy/logoffPanel.java
shaggy/mainPanel.java
shaggy/message.java [new file with mode: 0644]
shaggy/messagePanel.java
shaggy/net.java
shaggy/pageWindow.java [deleted file]
shaggy/room.java [new file with mode: 0644]
shaggy/roomCmp.java [new file with mode: 0644]
shaggy/roomFrame.java [new file with mode: 0644]
shaggy/roomInfo.java [new file with mode: 0644]
shaggy/roomMap.java
shaggy/roomPassPrompt.java [deleted file]
shaggy/sorter.java
shaggy/whoWindow.java [deleted file]
shaggy/zapPrompt.java [deleted file]

diff --git a/shaggy/CallBack.java b/shaggy/CallBack.java
new file mode 100644 (file)
index 0000000..7542ec7
--- /dev/null
@@ -0,0 +1,3 @@
+public interface CallBack {
+  public void run( citReply r );
+}
diff --git a/shaggy/MsgCmd.java b/shaggy/MsgCmd.java
new file mode 100644 (file)
index 0000000..cfc7a77
--- /dev/null
@@ -0,0 +1,20 @@
+public class MsgCmd implements Runnable {
+  String       cmd, data;
+  CallBack     cb;
+  citReply     r;
+
+  public MsgCmd( String cmd, String data, CallBack cb ) {
+    this.cmd = cmd;
+    this.data = data;
+    this.cb = cb;
+  }
+
+  public void setReply( citReply r ) {
+    this.r = r;
+  }
+
+  public void run() {
+    if( cb != null )
+      cb.run( r );
+  }
+}
diff --git a/shaggy/NamedPanel.java b/shaggy/NamedPanel.java
deleted file mode 100644 (file)
index 567b9f8..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-import java.awt.*;
-
-public class NamedPanel extends Panel {
-       public static final int         LEFT=0, CENTER=1, RIGHT=2;
-       public static final int         TOP=0, MIDDLE=1, BOTTOM=2;
-
-       boolean         clean;
-
-       int             x_tl, y_tl;
-       int             x_tlm, y_tlm;
-       int             x_trm, y_trm;
-       int             x_tr, y_tr;
-       int             x_br, y_br;
-       int             x_bl, y_bl;
-
-       String          name;
-       int             h_alignment, v_alignment;
-
-       int             name_width, name_height, name_a_height;
-       Color           back, nw, se;
-       Insets          border, pane;
-       Insets          theInsets;
-       Dimension       old_size;
-
-       NamedPanel( String name ) {
-               this( name, LEFT, MIDDLE );
-               }
-
-       NamedPanel( String name, int h_alignment ) {
-               this( name, h_alignment, MIDDLE );
-               }
-
-       NamedPanel( String name, int h_alignment, int v_alignment ) {
-               border = new Insets( 4, 4, 4, 4 );
-               pane = new Insets( 4, 4, 4, 4 );
-
-               theInsets = addInsets( border, pane );
-
-               this.name = name;
-               this.h_alignment = h_alignment;
-               this.v_alignment = v_alignment;
-               clean = false;
-               }
-
-       public void addNotify() {
-               super.addNotify();
-               fontBox();
-
-               theInsets = addInsets( border, pane );
-               theInsets.top += name_height;
-               validate();
-               }
-
-       final public Insets addInsets( Insets i1, Insets i2 )
-               {
-               return new Insets( i1.top + i2.top, i1.left + i2.left, i1.bottom + i2.bottom, i1.right + i2.right );
-               }
-
-       public Insets insets() {
-               return theInsets;
-               }
-
-       public Insets getInsets() {
-               return theInsets;
-               }
-
-       public void setLabel( String name ) {
-               this.name = name;
-               clean = false;
-               repaint();
-               }
-
-       public void align( int alignment ) {
-               h_alignment = alignment;
-               clean = false;
-               }
-
-       public void paint( Graphics g ) {
-               super.paint( g );
-
-               Dimension       tmp = size();
-               
-               if( (!clean) || ((tmp.width != old_size.width) || (tmp.height != old_size.height) )  ) {
-                       old_size = tmp;
-
-                       calculateCrap();
-                       clean = true;
-//                     g.clearRect( 0, 0, tmp.width, tmp.height);
-                       }
-
-               g.setColor( nw );
-               g.drawLine( x_tl, y_tl, x_tlm, y_tlm );
-               g.drawLine( x_trm, y_trm, x_tr, y_tr );
-               g.drawLine( x_bl, y_bl, x_tl, y_tl );
-
-               g.drawLine( x_tr-1, y_tr+1, x_br-1, y_br-1 );
-               g.drawLine( x_bl+1, y_bl-1, x_br-1, y_br-1 );
-
-               g.drawLine( x_trm, y_trm, x_trm, y_trm+1 );
-
-               g.setColor( se );
-               g.drawLine( x_tl+1, y_tl+1, x_tlm-1, y_tlm+1 );
-               g.drawLine( x_trm+1, y_trm+1, x_tr-1, y_tr+1 );
-               g.drawLine( x_bl+1, y_bl-1, x_tl+1, y_tl+1 );
-
-               g.drawLine( x_tr, y_tr+1, x_br, y_br );
-               g.drawLine( x_bl+1, y_bl, x_br, y_br );
-
-               g.drawLine( x_tlm, y_tlm, x_tlm, y_tlm+1 );
-
-               g.setColor( getForeground() );
-               g.drawString( name, x_tlm + 5, border.top+name_a_height );
-               }
-
-       void fontBox() {
-               FontMetrics     fm = getFontMetrics( getFont() );
-
-               name_height = fm.getMaxAscent() + fm.getMaxDescent();
-               name_a_height = fm.getMaxAscent();
-               name_width = fm.stringWidth( name );
-               }
-
-       void calculateCrap() {
-               fontBox();
-
-               back = getBackground();
-               se = back.brighter();
-               nw = back.darker();
-
-               x_tl = border.left;
-               y_tl = border.top;
-
-               switch( v_alignment ) {
-                       default: break;
-                       case MIDDLE: y_tl += name_height/2; break;
-                       case BOTTOM: y_tl += name_height; break;
-                       }
-
-               x_tr = old_size.width - border.left;
-               y_tr = y_tl;
-
-               x_br = x_tr;
-               y_br = old_size.height - border.bottom;
-
-               x_bl = x_tl;
-               y_bl = y_br;
-
-               y_tlm = y_trm = y_tl;
-
-               switch( h_alignment ) {
-                       default:
-                               x_tlm = x_tl + 20;
-                               x_trm = x_tlm + name_width + 8;
-                               break;
-                       case CENTER:
-                               x_tlm = (x_tl + (x_tr - x_tl)/2) - name_width/2 - 5;
-                               x_trm = x_tlm + name_width + 8;
-                               break;
-                       case RIGHT:
-                               x_trm = x_tr - 5;
-                               x_tlm = x_trm - (name_width + 8);
-                               break;
-                       }
-               }
-       }
index e300554cc6448df1fdf19ad3f06b903b41e36778..94df50f21c17391cf9a13ac2949776af9a9bbea7 100644 (file)
@@ -4,38 +4,46 @@
 
 import java.awt.*;
 
-public class PairPanel extends Panel
-       {
-       GridBagLayout           gbLayout;
-       GridBagConstraints      gbLeft, gbRight;
-
-       PairPanel() {
-               this( 0, 0 );
-               }
-
-       PairPanel( int x, int y ) {
-               setLayout( gbLayout = new GridBagLayout() );
-
-               gbLeft = new GridBagConstraints();
-               gbLeft.gridwidth = 1;
-               gbLeft.ipadx = x;
-               gbLeft.ipady = y;
-               gbLeft.anchor = GridBagConstraints.EAST;
-
-               gbRight = new GridBagConstraints();
-               gbRight.ipadx = x;
-               gbRight.ipady = y;
-               gbRight.gridwidth = GridBagConstraints.REMAINDER;
-               gbRight.anchor = GridBagConstraints.WEST;
-               }
-
-       public void addLeft( Component c ) {
-               gbLayout.setConstraints( c, gbLeft );
-               add( c );
-               }
-
-       public void addRight( Component c ) {
-               gbLayout.setConstraints( c, gbRight );
-               add( c );
-               }
-       }
+public class PairPanel extends Panel {
+  GridBagLayout           gbLayout;
+  GridBagConstraints      gbLeft, gbRight;
+
+  PairPanel() {
+    this( 0, 0 );
+  }
+
+  PairPanel( int x, int y ) {
+    Insets             i = null;
+
+    if( x + y != 0 )
+      i = new Insets( x, y, x, y );
+
+    setLayout( gbLayout = new GridBagLayout() );
+
+    gbLeft = new GridBagConstraints();
+    gbLeft.gridwidth = 1;
+    //    gbLeft.ipadx = x;
+    //    gbLeft.ipady = y;
+    if( i != null )
+      gbLeft.insets = i;
+    gbLeft.anchor = GridBagConstraints.EAST;
+
+    gbRight = new GridBagConstraints();
+    //    gbRight.ipadx = x;
+    //    gbRight.ipady = y;
+    if( i != null )
+      gbRight.insets = i;
+    gbRight.gridwidth = GridBagConstraints.REMAINDER;
+    gbRight.anchor = GridBagConstraints.WEST;
+  }
+
+  public void addLeft( Component c ) {
+    gbLayout.setConstraints( c, gbLeft );
+    add( c );
+  }
+
+  public void addRight( Component c ) {
+    gbLayout.setConstraints( c, gbRight );
+    add( c );
+  }
+}
diff --git a/shaggy/Panel3D.java b/shaggy/Panel3D.java
deleted file mode 100644 (file)
index 25479c6..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-import java.awt.*;
-
-public class Panel3D extends Panel
-       {
-       static final int        LOWER = 1;
-       static final int        HIGHER = 0;
-       static final int        RIDGE = 2;
-
-       public Insets   outside, ridge, plane;
-       int             state = 0;
-       
-       public Panel3D( )
-               {
-               setUp( HIGHER, null, null, null );
-               }
-
-       public Panel3D( int state )
-               {
-               setUp( state, null, null, null );
-               this.state = state;
-               }
-       
-       public Panel3D( int state, Insets outside )
-               {
-               setUp( state, outside, null, null );
-               }
-       
-       public Panel3D( int state, Insets outside, Insets ridge )
-               {
-               setUp( state, outside, ridge, null );
-               }
-       
-       public Panel3D( int state, Insets outside, Insets ridge, Insets plane )
-               {
-               setUp( state, outside, ridge, plane );
-               }
-
-       public void setUp( int state, Insets outside, Insets ridge, Insets plane )
-               {
-               this.state              = state;
-               
-               this.outside    = (outside == null)     ? new Insets( 3, 3, 3, 3 ) : outside;
-               this.ridge              = addInsets( this.outside, (ridge == null) ? new Insets( 3, 3, 3, 3 ) : ridge );
-               this.plane              = addInsets( ( (state & RIDGE) == RIDGE) ? this.ridge: this.outside, (plane == null ) ? new Insets( 4, 4, 4, 4 ) : plane );
-               }
-
-       final public Insets addInsets( Insets i1, Insets i2 )
-               {
-               return new Insets( i1.top + i2.top, i1.left + i2.left, i1.bottom + i2.bottom, i1.right + i2.right );
-               }
-
-       public void paint( Graphics g )
-               {
-               super.paint( g );
-               Dimension d = size();
-               Color bg = getBackground();
-
-               g.setColor(bg);
-               g.draw3DRect( outside.left, outside.top, d.width - outside.right - outside.left, d.height - outside.top - outside.bottom, (state & LOWER) != LOWER );
-               if( (state & RIDGE) == RIDGE )
-                       g.draw3DRect( ridge.left, ridge.top, d.width - ridge.right - ridge.left, d.height - ridge.top - ridge.bottom, (state & LOWER) == LOWER ); 
-
-               }
-
-       public Insets insets() {
-               return plane;
-               }
-
-       public Insets getInsets() {
-               return plane;
-               }
-       }
-       
-
diff --git a/shaggy/Queue.java b/shaggy/Queue.java
new file mode 100644 (file)
index 0000000..fb567fd
--- /dev/null
@@ -0,0 +1,44 @@
+public class Queue {
+       QElement        head, tail;
+
+       Queue() {
+               head = tail = null;
+               }
+
+       public synchronized void append( Object o ) {
+               if( tail == null )
+                       head = tail = new QElement( o );
+               else {
+                       tail.next = new QElement( o );
+                       tail = tail.next;
+                       }
+               notifyAll();
+               }
+
+       public synchronized Object get() {
+               try {
+                       while( head == null )
+                               wait();
+                       } catch( InterruptedException ie ) {
+                               return null;
+                       }
+
+               Object          o = head.theData;
+               head = head.next;
+
+               if( head == null )
+                       tail = null;
+               return o;
+               }
+       }
+
+class QElement {
+       QElement        next;
+       Object          theData;
+
+       QElement( Object o ) {
+               next = null;
+               theData = o;
+               }
+       }
+
index 85d2cfb9d97d256293be3d5b8e16e6aa79d93bbf..f17791373f9671a5a71b7619823df1e0fa484d29 100644 (file)
@@ -1,14 +1,11 @@
 Shaggy: java-powered citadel/ux client
 by Will Schenk (chilly@alumni.psu.edu, chilly @ uncnsrd)
 
-Last mod: 27 Jul 1999
+Last mod: 04 Aug 1999
 
-This is the java client.  I would like this to be both an application and
-an applet.  Mostly this should be straight forward, but with an applet
-you're stuck in the "sandbox" so connecting to a different bbs won't work
-(unless you set up some sort of ugly proxy) and I'm not sure how downloading
-files will work -- there may be an ugly way using Applet.showUrl()
-to make it possible.
+This is the java client.  It has been re-written to be multithreaded and to
+use the JFC/Swing library.  You need Swing for this application to work;
+either with Java > 1.1.3, or Java 1.2 (aka Java 2).
 
 At the moment, my aim is just use this client to connect, so basically 
 that means that I should get the client to do all the stuff that I use 
@@ -22,15 +19,6 @@ layout the gui and it's behavior.  Ideas are welcome.
 I'll try and keep the STATUS file up-to-date with the current niftyness
 of the features and lack thereof.
 
-I'm developing with sun's jdk 1.1.7 (linuxppc) but trying to stay with
-the 1.0.2 api.  This is for two reasons: 1) I know the 1.0 api well
-enough so I don't have to go messing around with the docs to figure out
-the calls and 2) if we do want to use this as an applet it will allow
-the largest availability of compatable browsers.  (netscape implemented
-1.1 in 4.0, but not the new awt event model (I think it wasn't until 4.05).
-IE did something similarily goofy.)  Ergo, there will be many complaints
-about using a deprecated api when compiling.
-
 - BUILDING
 I've including a copy of my "java make script", a perl script called "jmake".
 Assuming javac is in your path and nothing funky is going on with your
@@ -64,4 +52,12 @@ ideally, when it's distributed there should be either a zip or jar file
 (both are actually zip files, only difference is the letters) with all the
 classes.  This makes the applet load faster, and it's cleaner.
 
+REMEMBER: if you are using java 1.1.x, you'll need to download the swing
+libraries.  To use the libraries, you will need to put them in the
+CLASSPATH environment variable, or pass them on the command line.  Remember
+to put "." in the classpath.  
+
+example:
+export CLASSPATH=.:/usr/local/jdk/lib/classes.zip:/usr/local/swing/swingall.jar
+
 -- will 
index 940ee01ff8d4072ec024b03ca21d3f49cd510e6f..99d3a6b3e414b13e605430ca80faa886e8bb73dd 100644 (file)
@@ -1,4 +1,4 @@
-mod: 29 Jul 1999
+mod: 04 Aug 1999
 
 Basic:
 - Connect to server and login (connects, gets "hello" and throws up window)
@@ -6,33 +6,33 @@ Basic:
 - can log off (shows goodbye, and in application lets you connect to a
   different server)
 
-- can recieve express messages (GEXP style, will get all messages that
+* can't recieve express messages (GEXP style, will get all messages that
   are there.
-- can send and "reply" to express messages, uses either single or multi
+* can't send and "reply" to express messages, uses either single or multi
   depending on server support.
-- who is online (double clicking on list will send express msg to user)
+* no who is online
 - supports the IDEN command
+- Automaticcaly goes to mail room if you have new messages
 * can't change password or other config stuff
 
 
 "main"
 - Splits rooms up into new and no-new
- * limited floor support (shows in message panel)
+- floor support
 - rooms are now sorted
 
 - Go to next room with messages
 - go to any old room by double-clicking from list
-- can get to hidden or guessable-named rooms
-- can go to password protected rooms (tested)
-- can zap rooms
- * can't list zapped rooms
+* can't get to hidden or guessable-named rooms
+* can't go to password protected rooms (tested)
+* can't zap rooms
+* can't list zapped rooms
 
 "message"
 - read new, all, or last-5 message in a room
-- forward and 
+- forward and  reverse
 - enter messages in room (only type 0)
- - handles Mail room, but 1) depends on the fact that the room is named
-   "Mail" (ie: doesn't pass the flag returned from GOTO)
+- handles Mail room
 * doesn't say anything about having mail or going there first, just lists
   Mail in the "new" list.
 * No reply button when in mail room.
@@ -44,6 +44,6 @@ Basic:
   go to the next room, the three unread messages will still be unread with
   the java client while they wouldn't be with the text client.  I like it
   better personally, but hey, that's me.
-- can view room info
+* can't view room info
 
 everything else isn't done.
index 5025ea11b6ddff4bb7ab90cb085b0a2ec5d3c48a..1523fe61feaf877f6a1169cfa6b0d20a55436f4a 100644 (file)
@@ -11,7 +11,7 @@ public class SortedVector {
        
   public SortedVector() {
     theList = new Vector();
-    cmpr = null;
+    cmpr = new sorter();
   }
 
   public SortedVector( sorter s ) {
@@ -23,10 +23,7 @@ public class SortedVector {
     int                i, cmp;
     for( i = 0; i < theList.size(); i++ ) {
 
-      if( cmpr == null )
-       cmp = ((String)theList.elementAt(i)).compareTo( (String)theId );
-      else
-       cmp = cmpr.cmp( theList.elementAt( i ), theId );
+      cmp = cmpr.cmp( theList.elementAt( i ), theId );
 
       if( cmp == 0 ) return -1;
       if( cmp > 0 )
@@ -53,10 +50,7 @@ public class SortedVector {
   public int removeElement( Object theItem ) {
     for( int i = 0; i < theList.size(); i++ ) {
       boolean equal;
-      if( cmpr == null )
-       equal = ((String)theList.elementAt( i )).equalsIgnoreCase( (String)theItem );
-      else
-       equal = cmpr.cmp( theList.elementAt( i ), theItem ) == 0;
+      equal = cmpr.cmp( theList.elementAt( i ), theItem ) == 0;
       if( equal ) {
        theList.removeElementAt( i );
        return i;
@@ -67,13 +61,8 @@ public class SortedVector {
        
   public boolean isElement( Object theItem ) {
     for( int i = 0; i < theList.size(); i++ ) {
-      if( cmpr == null ) {
-       if( ((String)theList.elementAt( i )).equalsIgnoreCase( (String)theItem ) )
-         return true;
-      } else {
-       if( cmpr.cmp( theList.elementAt( i ), theItem ) == 0 )
-         return true;
-      }
+      if( cmpr.cmp( theList.elementAt( i ), theItem ) == 0 )
+       return true;
     }
     return false;
   }
diff --git a/shaggy/citGui.java b/shaggy/citGui.java
new file mode 100644 (file)
index 0000000..f6ce7a3
--- /dev/null
@@ -0,0 +1,81 @@
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+
+public class citGui {
+  JFrame       frame;
+  CardLayout   cdLayout;
+  Container    c;
+  hostPanel    hp;
+  loginPanel   lp;
+  mainPanel    mp;
+  logoffPanel  lfp;
+
+  public citGui() {
+    frame = new JFrame( "Shaggy" );
+    c = frame.getContentPane();
+
+    c.setLayout( cdLayout = new CardLayout() );
+    c.add( "Host", hp = new hostPanel() );
+    c.add( "Login", lp = new loginPanel() );
+    c.add( "Main", mp = new mainPanel() );
+    c.add( "Logoff", lfp = new logoffPanel() );
+
+    frame.addWindowListener( new WindowAdapter() {
+      public void windowClosing( WindowEvent e ) {
+       citadel.me.closeFrame();
+       System.exit( 0 );
+      }
+    });
+
+    frame.pack();
+    frame.setVisible( true );
+  }
+
+  public void showHostBrowser() {
+    cdLayout.show( c, "Host" );
+    hp.refresh();
+  }
+
+  public void showLoginPanel() {
+    cdLayout.show( c, "Login" );
+    lp.refresh();
+  }
+
+  public void showLoginPanel( String user, String pass ) {
+    showLoginPanel();
+    lp.setDefault( user, pass );
+    if( (user == null) || (user.length()==0) ||
+       (pass == null) || (pass.length()==0) ) return;
+    citadel.me.authenticate( user, pass );
+  }
+
+  public void showMainPanel() {
+    cdLayout.show( c, "Main" );
+    mp.refresh();
+  }
+
+  public void showLogoffPanel() {
+    cdLayout.show( c, "Logoff" );
+    lfp.refresh();
+  }
+
+  public void errMsg( String reason ) {
+    JOptionPane.showMessageDialog(frame,
+                                 reason,
+                                 "Inane error",
+                                 JOptionPane.ERROR_MESSAGE);
+  }
+
+  public void warning( String text ) {
+    JOptionPane.showMessageDialog(frame,
+                                 text,
+                                 "What is this?",
+                                 JOptionPane.WARNING_MESSAGE);
+  }
+}
+
+
+
+
index 172be7e6107590792db6c6968c3e2b23c5733324..931a5a258997923c17e6672f4b4d196625c6bb04 100644 (file)
-/* citadel.java
- *
- * the "main" object
- */
-
-import java.util.*;
-import java.net.InetAddress;
 
 public class citadel {
-  public static String         VERSION="0.0";
-
-  String                       host;
-  boolean                      applet;
-  net                          theNet;
-  server                       serverInfo;
-  user                         theUser;
-  private citPanel                     cp;
-
-  boolean                      floors;
-  whoWindow                    wo;
-  roomMap                      rooms;
-
-  public static citadel        me;
-
-  public static void main( String args[] ) {
-    citadel cb = new citadel( false );
-    if( args.length > 0 )
-      cb.openConnection( args[0] );
-    else
-      cb.openConnection();
-    citFrame cf = new citFrame();
-  }
-
-  public static int atoi( String s ) {
-    try {
-      return Integer.parseInt( s );
-    } catch( Exception e ) {
-      return 0;
-    }
-  }
-
-  public citadel( boolean applet ) {
-    me = this;
-    this.applet = false;
-    theUser = null;
-    wo = null;
-    rooms = new roomMap();
-  }
-
-  public void setCitPanel( citPanel cp ) {
-    this.cp = cp;
-  }
-
-  public void lostNetwork( String reason ) {
-    theNet = null;
-    if( cp == null )
-      System.out.println( "lost network connection:" + reason );
-    else
-      cp.logoff( "lost network connection: " + reason );
-  }
-
-  public boolean openConnection( ) {
-    return openConnection( "127.0.0.1" );
-  }
-
-  public boolean openConnection( String host ) {
-    this.host = host;
-    if( theNet == null ) theNet = new net( );
-
-    if( theNet.connect(host) ) {
-      System.out.println( "Connected to server." );
-
-      getReply( "IDEN 0|7|" + VERSION + "|Shaggy " + VERSION + " (" + getArch() + ")|" + getHostName() );
-      citReply rep = theNet.getReply( "INFO" );
-      if( rep.listingFollows() )
-       serverInfo = new server( rep );
-
-      return true;
-    }
-    else {
-      System.out.println( "Couldn't connect to server." );
-    }
-    return false;
-  }
-
-  public String getArch() {
-    try {
-      Properties       p = System.getProperties();
-      return p.get( "os.name" ) + "/" + p.get( "os.arch" );
-    } catch( SecurityException se ) {
-      return "<unknown>";
-    }
-  }
-
-  public String getHostName() {
-    try {
-      InetAddress      me = InetAddress.getLocalHost();
-      return me.getHostName();
-    } catch( Exception e ) {
-      return "dunno";
-    }
-  }
-
-  public String getBlurb() {
-    if( serverInfo != null ) return serverInfo.blurb;
-    return "";
-  }
-
-  public String getSystemMessage( String name ) {
-    citReply rep = getReply( "MESG " + name );
-    if( (rep != null) && rep.listingFollows() )
-      return rep.getData();
-    else
-      return "Couldn't find " + name;
-  }
-
-  public void loggedIn( citReply r ) {
-    theUser = new user( r );
-    floors = serverInfo.floor_flag != 0;
-    floors &= theUser.floors();
-    cp.mainMenu();
-  }
-
-  public boolean floors() {
-    return floors;
-  }
-
-  public citReply getReply( String s ) {
-    return getReply( s, (String)null );
-  }
-
-  public citReply getReply( String s, String d ) {
-    if( theNet == null ) return null;
-
-    return theNet.getReply( s,d  );
-  }
-
-  public void gotoRoom( ) {
-    gotoRoom( null, false );
-  }
-
-  public void gotoRoom( String name, boolean flag ) {
-    new promptWindow( new gotoPrompt( name ) );
-  }
-
-  public void enterRoom( String room ) {
-    enterRoom( room, null );
-  }
-
-  public void enterRoom( String room, String pass ) {
-    String cmd = "GOTO " + room;
-    if( pass != null )
-      cmd = cmd + "|" + pass;
-    citReply   r=getReply( cmd );
-    if( r.ok() ) {
-      rooms.visited( room );
-      cp.enterRoom( r );
-    } else if( r.res_code == 540 ) /* ERROR+PASSWORD_REQUIRED */
-      new promptWindow( new roomPassPrompt( room ) );
-  }
-
-  public void showMsgPane() {
-    cp.deck.show( cp, "Message" );
-  }
-
-  public void login() {
-    cp.login();
-  }
-
-  public void mainMenu() {
-    cp.mainMenu();
-  }
-
-  public void enterMsg( String room ) {
-    cp.enterMsg( room );
-  }
-
-  public void nextNewRoom() {
-    enterRoom( rooms.nextNewRoom() );
-  }
-
-  public void expressMsg() {
-    citReply   r=getReply( "GEXP" );
-    System.out.println( "EXPRESS MSG" );
-    if( !r.error() ) new expressWindow( r );
-  }
-
-  public void sendMessage( String body, String rec, boolean mail ) {
-    String cmd = "ENT0 1|";
-    if( mail ) cmd = cmd + rec;
-    cmd = cmd + "|0|0|0";
-
-    citReply   r = getReply( cmd, body );
-    if( r.error() )
-      error( r );
-  }
-
-  public void logoff() {
-    rooms.clear();
-    cp.logoff(null);
-    getReply( "QUIT" );
-  }
-
-  public void who_online() {
-    if( wo == null )
-      wo = new whoWindow();
-    else
-      wo.show();
-  }
-
-  public void page_user() {
-    page_user( null );
-  }
-
-  public void page_user( String who ) {
-    new pageWindow( who );
-  }
-
-  public void error( citReply r ) {
-    System.out.println( r.line );
-  }
+    public final static String NAME="Shaggy", VERSION="0.1";
+    public static citadel      me;
+
+    String             server;
+    int                        port;
+
+    citGui             cg;
+    net                        theNet;
+
+    server             serverInfo;
+    user               theUser;
+    roomMap            rooms;
+    roomFrame          rf;
+
+    public static void main( String args[] ) {
+       new citadel();
+    }
+
+    public static int atoi( String s ) {
+       if( s == null ) return 0;
+       try {
+           return Integer.parseInt( s );
+       } catch( NumberFormatException nfe ) {
+           return 0;
+       }
+    }
+
+    public citadel() {
+       me = this;
+       cg = new citGui();
+       theNet = new net();
+       serverInfo = null;
+       rf = null;
+    }
+
+    public void showHostBrowser() {
+       cg.showHostBrowser();
+    }
+
+    public void setServer( String server, String port ) {
+       int     p = atoi( port );
+       if( p == 0 ) p = 504;
+       setServer( server, p );
+    }
+
+    public void setServer( String server, int port ) {
+       this.server = server;
+       this.port = port;
+
+       Thread  t = new Thread( theNet );
+       t.start();
+    }
+
+    public void setServerInfo( server s ) {
+       serverInfo = s;
+    }
+
+    public void showLoginPanel() {
+       cg.showLoginPanel();
+    }
+
+    public void showLoginPanel( String user, String pass ) {
+       cg.showLoginPanel( user, pass );
+    }
+
+    public void showMainPanel() {
+       cg.showMainPanel();
+    }
+
+    public void expressMsg() {
+       System.out.println( "got an express message!" );
+    }
+
+    public void gotoRoom( String name ) {
+       System.out.println( "goto room:" + name );
+    }
+
+    public void lostNetwork( String reason ) {
+       cg.errMsg( reason );
+       cg.showHostBrowser();
+    }
+
+    public void warning( String text ) {
+       cg.warning( text );
+    }
+
+    public void closeFrame() {
+       System.out.println( "Closed the friggin frame." );
+    }
+
+    public void networkEvent( String cmd ) {
+       networkEvent( cmd, null, null );
+    }
+
+    public void networkEvent( String cmd, CallBack cb ) {
+       networkEvent( cmd, null, cb );
+    }
+
+    public void networkEvent( String cmd, String data, CallBack cb ) {
+       theNet.append( new MsgCmd( cmd, data, cb ) );
+    }
+
+    public void getServerInfo( CallBack        cb ) {
+       networkEvent( "INFO", cb );
+    }
+
+    public void getSystemMessage( String f_name, CallBack cb ) {
+       networkEvent( "MESG " + f_name, cb );
+    }
+
+    public void authenticate( final String user, final String pass ) {
+       networkEvent( "USER " + user, new CallBack() {
+           public void run( citReply r ) {
+               if( r.moreData() ) {
+                   networkEvent( "PASS "+ pass, new CallBack() {
+                       public void run( citReply r ) {
+                           if( r.error() ) {
+                               warning( "Wrong Password" );
+                           } else {
+                               citadel.me.setUser( new user( r ) );
+                           }
+                       } });
+               } else {
+                   warning( user + ":No such user" );
+               }
+           }
+       } );
+    }
+
+    public void enterRoom( String s ) {
+       enterRoom( s, null );
+    }
+
+    public void enterRoom( String s, String p ) {
+       enterRoom( cg.mp.rooms.getRoom( s ), p );
+    }
+
+    public void enterRoom( room r ) {
+       enterRoom( r, null );
+    }
+
+    public void enterRoom( final room rm, String pass ) {
+       String  cmd = "GOTO " + rm.name;
+       if( pass != null )
+           cmd = cmd + "|" + pass;
+
+       networkEvent( cmd, new CallBack() {
+           public void run( citReply r ) {
+               if( r.ok() ) {
+                   System.out.println( "Going to room: " + rm.name );
+                   rm.setNew( false );
+
+                   roomInfo    ri = new roomInfo( rm, r );
+
+                   /* check ri.mail and act accordingly */
+
+                   if( rf == null )
+                       rf = new roomFrame();
+
+                   rf.setRoom( ri );
+                   cg.mp.updateLists( rooms.getFloor().name() );       // hack
+               } else if( r.res_code == 540 ) {
+                   System.out.println( "NEED A PASSWORD FOR THIS ROOM" );
+               }
+           } } );
+    }
+
+    public void logoff() {
+       /* close windows */
+       if( rf != null )
+           rf.dispose();
+       rf = null;
+       cg.showLogoffPanel();
+       networkEvent( "QUIT", new CallBack() {
+           public void run( citReply r ) {
+               theNet.done();
+           } } );
+    }
+
+    public void setUser( user theUser ) {
+       this.theUser = theUser;
+       showMainPanel();
+       networkEvent( "CHEK", new CallBack() {
+           public void run( citReply r ) {
+               int     msg = atoi( r.getArg( 0 ) );
+               if( msg != 0 )
+                   enterRoom( "Mail" );
+           } } );
+    }
+
+    public boolean floors() {
+       return true;    // FIXME
+    }
 }
+
+
diff --git a/shaggy/displayInfo.java b/shaggy/displayInfo.java
deleted file mode 100644 (file)
index b6cde78..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* displayInfo.java
- * Display room's info
- */
-
-import java.awt.*;
-
-public class displayInfo extends Frame {
-  String       name;
-  TextArea     text;
-
-  public displayInfo( String name ) {
-    super( "Info for : " + name );
-
-    this.name = name;
-    setLayout( new BorderLayout() );
-
-    add( "Center", text = new TextArea() );
-    Panel p;
-    add( "South", p = new Panel() );
-    p.add( new Button( "Close" ) );
-
-    citReply   r = citadel.me.getReply( "RINF" );
-    if( r.listingFollows() )
-      text.append( r.getData() );
-    else
-      text.append( "<no room info>" );
-    resize( 300, 300 );
-    show();
-  }
-
-  public boolean handleEvent( Event e ) {
-    if( e.id == Event.WINDOW_DESTROY )
-      dispose();
-    return super.handleEvent( e );
-  }
-
-  public boolean action( Event e, Object o ) {
-    if( e.target instanceof Button )
-      dispose();
-    return super.action( e, o );
-  }
-}
index e956339f7e29c85edab10fadd1100c32558df3ed..f175a9117157bb6bc690324bc78dd0867d04624f 100644 (file)
@@ -1,83 +1,63 @@
-/* enterPanel.java
- * For entering messages
- */
-
+import javax.swing.*;
 import java.awt.*;
+import java.awt.event.*;
 
-public class enterPanel extends Panel {
-  boolean      mail;
-  String       room, recip;
-  NamedPanel   np;
-
-  TextField    who;
-  TextArea     msg;
+/* Quick quick quick hack */
 
-  Button       ok, cancel;
+public class enterPanel extends JPanel{
+    roomFrame  rf;
+    roomInfo   ri;
 
-  public enterPanel() {
-    PairPanel  pp = new PairPanel();
-    pp.addLeft( new Label( "Recipient : " ) );
-    pp.addRight( who = new TextField( 10 ) );
+    JTextField to;
+    JTextArea  msg;
 
-    setLayout( new BorderLayout() );
-    add( "North", pp );
+    public enterPanel( final roomFrame rf ) {
+       this.rf = rf;
+       setLayout( new BorderLayout() );
 
-    np = new NamedPanel( "room name" );
-    np.setLayout( new BorderLayout() );
-    np.add( "Center", msg = new TextArea() );
+       add( "North", to = new JTextField() );
+       to.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               msg.requestFocus();
+           } } );
 
-    add( "Center", np );
+       add( "Center", msg = new JTextArea() );
 
-    Panel p = new Panel();
+       JPanel  p = new JPanel();
+       JButton b;
 
-    p.add( ok = new Button ( "Send" ) );
-    p.add( cancel = new Button ( "Cancel" ) );
-    add( "South", p );
-    mail = false;
-  }
+       p.add( b = new JButton( "Send" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               String cmd = "ENT0 1|";
 
-  public void refresh( String room, String r ) {
-    if( room.equalsIgnoreCase( "Mail" ) ) {
-      who.enable();
-      who.setText( r );
-      if( r == null )
-       who.requestFocus();
-      else
-       msg.requestFocus();
-      mail = true;
-    } else {
-      who.disable();
-      who.setText( "DISABLED" );
-      msg.requestFocus();
-      mail = false;
-    }
+               if( ri.mail ) cmd = cmd + to.getText();
+               cmd = cmd+"|0|0|0";
 
-    msg.setText( "" );
+               System.out.println( msg.getText() );
+               citadel.me.networkEvent( cmd, msg.getText(), new CallBack() {
+                   public void run( citReply r ) {
+                       if( r.error() )
+                           citadel.me.warning( r.getArg(0) );
+                       rf.showRoom();
+                   } } );
+           }
+       } );
 
-    np.setLabel( room + (citadel.me.floors() ? 
-                " (" + citadel.me.rooms.getRoomsFloorName( room  )+")" : "" ) );
-    this.room = room;
-    this.recip = r;
+       p.add( b = new JButton( "Cancel" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               rf.showRoom();
+           } } );
 
-    msg.enable();
-    if( !mail ) {
-      citReply rep = citadel.me.getReply( "ENT0 0|0|0|0|0" );
-      if( !rep.ok() ) {
-       msg.setText( "You aren't allowed to post here." );
-       msg.disable();
-      }
+       add( "South", p );
     }
-  }
 
-  public boolean action( Event e, Object o ) {
-    if( e.target == ok ) {
-      System.out.println( who.getText() );
-      citadel.me.sendMessage( msg.getText(), who.getText(), mail );
-      citadel.me.showMsgPane();
-    } else if( e.target == cancel ) {
-      citadel.me.showMsgPane();
-      msg.requestFocus();
+    public void refresh( roomInfo ri ) {
+       this.ri = ri;
+       msg.setText( "" );
+       to.setText( "" );
+
+       to.setEnabled( ri.mail );
     }
-    return super.action( e, o );
-  }
 }
diff --git a/shaggy/floor.java b/shaggy/floor.java
new file mode 100644 (file)
index 0000000..4b6b056
--- /dev/null
@@ -0,0 +1,43 @@
+import java.util.*;
+
+public class floor {
+  String       name, num;
+  int          number, ref_count;
+  SortedVector rooms;
+
+  public floor( String l ) {
+    rooms = new SortedVector( new roomCmp() );
+
+    int        i = l.indexOf( '|' );
+    num = l.substring( 0, i );
+    number = citadel.atoi( num );
+
+    int        j = l.indexOf( '|', ++i );
+    name = l.substring( i, j );
+
+    ref_count = citadel.atoi( l.substring( j+1 ) );
+
+    /*    System.out.println( "floor name: " + name );
+    System.out.println( "number    : " + number );
+    System.out.println( "ref_count : " + ref_count );*/
+  }
+
+  public void addRoom( room r ) {
+    /*    System.out.println( "adding " + r.name() + " to " + name ); */
+    rooms.addElement( r );
+  }
+
+  public String num() {
+    return num;
+  }
+
+  public int number() {
+    return number;
+  }
+
+  public String name() {
+    return name;
+  }
+}
+
+
diff --git a/shaggy/hostPanel.java b/shaggy/hostPanel.java
new file mode 100644 (file)
index 0000000..15491cc
--- /dev/null
@@ -0,0 +1,82 @@
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class hostPanel extends JPanel {
+  JTextField   h_name, dns_name, port, user, pass;
+
+  public hostPanel() {
+    super( new BorderLayout() );
+
+    String[]   data = { 
+      "127.0.0.1",
+      "uncnsrd.mt-kisco.ny.us"
+    };
+
+    JPanel     p = new JPanel();
+    p.setBorder( BorderFactory.createTitledBorder( 
+                 BorderFactory.createEtchedBorder(), "Nodes" ) );
+
+    final JList        theList;
+
+    p.setLayout( new BorderLayout() );
+    p.add( "Center", new JScrollPane( theList = new JList( data ) ) );
+    add( "West", p );
+
+    MouseListener mouseListener = new MouseAdapter() {
+      public void mouseClicked(MouseEvent e) {
+       String  where = (String)theList.getSelectedValue();
+       if( where == null ) return;
+       dns_name.setText( where );
+       if (e.getClickCount() == 2) {
+         citadel.me.setServer( where, port.getText() );
+         citadel.me.showLoginPanel( user.getText(), pass.getText() );
+       }
+      }
+    };
+    theList.addMouseListener(mouseListener);
+
+
+    //    theList.setPrototypeCellValue("1 and 1 and 1 is 3");
+
+    PairPanel  pp = new PairPanel(3, 10);
+    pp.addLeft( new JLabel( "BBS Name:" ) );
+    pp.addRight( h_name = new JTextField( 20 ) );
+
+    pp.addLeft( new JLabel( "IP Address:" ) );
+    pp.addRight( dns_name = new JTextField( 20 ) );
+    dns_name.setText( "127.0.0.1" );
+   
+    pp.addLeft( new JLabel( "Port:" ) );
+    pp.addRight( port = new JTextField( "504" ) );
+
+    pp.addLeft( new JLabel( "Username:" ) );
+    pp.addRight( user = new JTextField( 10 ) );
+
+    pp.addLeft( new JLabel( "Password:" ) );
+    pp.addRight( pass = new JPasswordField( 10 ) );
+    add( "Center", pp );
+
+    JButton    but = new JButton( "Connect" );
+    but.addActionListener(new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       citadel.me.setServer( dns_name.getText(), port.getText() );
+       citadel.me.showLoginPanel( user.getText(), pass.getText() );
+      }
+    });
+
+    JPanel     pane = new JPanel();
+    pane.setBorder(BorderFactory.createEmptyBorder(30, //top
+                                                  30, //left   
+                                                  10, //bottom
+                                                  30) );//right
+
+    pane.add( but );
+    add( "South", pane );
+  }
+
+  public void refresh() {
+  }
+}
+
+
index 1ae46aa9ecfad7b66a9aa641210c04a17ab0b027..6952081c2ca6131b8bd8607fe765548530353d53 100644 (file)
@@ -1,89 +1,76 @@
-/* loginPanel.java
- * login screen
- */
-
+import javax.swing.*;
 import java.awt.*;
+import java.awt.event.*;
 
-public class loginPanel extends Panel {
-  TextArea     text;
-  TextField    user, pass;
-  Button       login;
+public class loginPanel extends JPanel {
+  JLabel       serverBlurb;
+  JTextArea    message;
+  JTextField   user, pass;
+  JButton      login;
 
   public loginPanel() {
     setLayout( new BorderLayout() );
+    add( "North", serverBlurb = new JLabel( "this is where you'd have server info" ) );
 
-    String     blurb = citadel.me.getBlurb();
-    if( blurb.length() == 0 ) blurb = "Citadel";
-
-    add( "North", new Label( blurb ) );
-    add( "Center", text = new TextArea() );
-
-    text.setFont( new Font( "Courier", Font.PLAIN, 12 ) );
+    JPanel     p = new JPanel();
+    p.setLayout( new BorderLayout() );
+    p.setBorder( BorderFactory.createTitledBorder( 
+                 BorderFactory.createEtchedBorder(), "Welcome Message" ) );
+    p.add( "Center", message = new JTextArea() );
+    add( "Center", p );
 
-    Panel      p = new Panel();
+    p = new JPanel();
     p.setLayout( new BorderLayout() );
 
-    PairPanel  pp = new PairPanel();
+    PairPanel  pp = new PairPanel( 4, 4 );
+    pp.addLeft( new JLabel( "User:" ) );
+    pp.addRight( user = new JTextField( 10 ) );
+    pp.addLeft( new JLabel( "Pass:" ) );
+    pp.addRight( pass = new JPasswordField( 10 ) );
 
-    pp.addLeft( new Label( "Username:" ) );
-    pp.addRight( user = new TextField( 10 ) );
-    pp.addLeft( new Label( "Password:" ) );
-    pp.addRight( pass = new TextField( 10 ) );
-    pass.setEchoCharacter( '.' );
+    user.addActionListener( new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       pass.requestFocus();
+      }
+    } );
 
-    p.add( "Center", pp );
+    pass.addActionListener( new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       citadel.me.authenticate( user.getText(), pass.getText() );
+      } } );
 
-    Panel      ppp = new Panel();
-    ppp.add( login = new Button( "Login" ) );
+    p.add( "Center", pp );
 
-    p.add( "East", ppp );
+  
+    p.add( "East", login = new JButton( "Login" ) );
+    login.addActionListener( new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       citadel.me.authenticate( user.getText(), pass.getText() );
+      } } );
 
     add( "South", p );
   }
 
-  public boolean handleEvent( Event e ) {
-    if( e.id == Event.GOT_FOCUS ) {
-      if( (e.target != user) && (e.target != pass) )
-       user.requestFocus();
-    }
-    return super.handleEvent( e );
-  }
-
-  public boolean action( Event e, Object o ) {
-    if( e.target == user ) {
-      pass.requestFocus();
-    }
-    if( (e.target == login) || (e.target == pass) ) {
-      String   u = user.getText(), p=pass.getText();
-
-      if( u.length() == 0 ) {
-       text.append( "\nNeed to enter in username.\n" );
-       user.requestFocus();
-      } else if (p.length() == 0 ) {
-       text.append( "\nNeed to enter in password.\n" );
-       pass.requestFocus();
-      } else {
-       citReply r = citadel.me.getReply( "USER " + u );
-       if( r.moreData() ) {
-         r = citadel.me.getReply( "PASS " + p );
-         if( r.error() ) {
-           text.append( "<bad password>" + r.getArg( 0 ) );
-         } else {
-           citadel.me.loggedIn( r );
-         }
-       } else {
-         text.append( "<bad user>" + r.getArg( 0 ) );
+  public void refresh() {
+    serverBlurb.setText( "Connecting..." );
+    message.setText( "" );
+    login.setEnabled( true );
+    citadel.me.getServerInfo( new CallBack() {
+      public void run( citReply r ) {
+       server  sI = new server( r );
+       serverBlurb.setText( sI.blurb );       
+       citadel.me.setServerInfo( sI );
+      }});
+    citadel.me.getSystemMessage( "hello", new CallBack() {
+      public void run( citReply r ) {
+       message.setText( r.getData() );
        }
-      }
-    }
-    return super.action( e, o );
+      });
   }
 
-  public void refresh() {
-    text.setText( "" );
-    user.setText( "" );
-    pass.setText( "" );
-    text.setText( citadel.me.getSystemMessage( "hello" ) );
+  public void setDefault( String user, String pass ) {
+    this.user.setText( user );
+    this.pass.setText( pass );
   }
 }
 
index a62273a4dc494d37f6c557647e401ce3cabfbccc..70177e3a6a378468a52c4029a603fa2a7226f0f2 100644 (file)
@@ -1,60 +1,41 @@
-/* logoffPanel.java
- * Display the "goodbye" message
- */
-
+import javax.swing.*;
 import java.awt.*;
+import java.awt.event.*;
 
-public class logoffPanel extends Panel {
-  TextArea     area;
-  TextField    host;
-  Button       connect,close;
-  boolean      applet;
+public class logoffPanel extends JPanel {
+  JLabel       serverBlurb;
+  JTextArea    message;
 
   public logoffPanel() {
-    applet = citadel.me.applet;
     setLayout( new BorderLayout() );
-
-    NamedPanel np = new NamedPanel("Disconnected");
-    np.setLayout( new BorderLayout() );
-
-    np.add( "Center", area = new TextArea() );
-    area.setFont( new Font( "Courier", Font.PLAIN, 12 ) );
-
-    add( "Center", np );
-
-    Panel      p = new Panel();
-
-    if( !applet ) {
-      p.add( host = new TextField(20) );
-      host.setText( citadel.me.host );
-    }
-
-    p.add( connect = new Button ( "Connect" ) );
-
-    if( !applet )
-      p.add( close = new Button( "Close" ) );
+    add( "North", serverBlurb = new JLabel( "blah" ) );
+
+    JPanel     p = new JPanel();
+    p.setLayout( new BorderLayout() );
+    p.setBorder( BorderFactory.createTitledBorder( 
+                 BorderFactory.createEtchedBorder(), "Goodbye Message" ) );
+    p.add( "Center", message = new JTextArea() );
+    add( "Center", p );
+
+    p = new JPanel();
+    /*     p.setLayout( new BorderLayout() ); */
+    JButton    b;
+    p.add( b = new JButton( "OK" ) );
+    b.addActionListener( new ActionListener() {
+      public void actionPerformed( ActionEvent e ) {
+       citadel.me.showHostBrowser();
+      }} );
 
     add( "South", p );
   }
 
-  public boolean action ( Event e, Object o ) {
-    if( (e.target == connect) || (e.target == host) ) {
-      if( !applet )
-       citadel.me.host = host.getText();
-
-      citadel.me.openConnection( citadel.me.host );
-      citadel.me.login();
-    } else if ( e.target == close ) {
-      System.out.println( "Thanks!" );
-      System.exit( 0 );
-    }
-    return super.action( e, o );
-  }
-
-  public void refresh( String s ) {
-    if( s == null )
-      area.setText( citadel.me.getSystemMessage( "goodbye" ) );
-    else
-      area.setText( s );
+  public void refresh() {
+    serverBlurb.setText( citadel.me.serverInfo.blurb );
+    message.setText( "" );
+    citadel.me.getSystemMessage( "goodbye", new CallBack() {
+      public void run( citReply r ) {
+       message.setText( r.getData() );
+       }
+      });
   }
 }
index 499d664385c5dca63af25b3269068ba31292d405..381e06da12dd36dd0f89dcda4006307ca5b2c071 100644 (file)
-/* mainPanel.java
- */
-
+import javax.swing.*;
 import java.awt.*;
-
-public class mainPanel extends Panel {
-  List         newL, oldL;
-  Button       next_room, goto_room;
-  Button       who_is_online, page_user;
-  Button       logout;
-
-  public mainPanel() {
-    setLayout( new BorderLayout() );
-
-    Panel      p = new Panel();
-    p.setLayout( new GridLayout( 1, 2 ) );
-
-    NamedPanel np = new NamedPanel( "New Messages" );
-    np.setLayout( new BorderLayout() );
-    np.add( "Center", newL = new List() );
-
-    p.add( np );
-
-    np = new NamedPanel( "Seen Messages" );
-    np.setLayout( new BorderLayout() );
-    np.add( "Center", oldL = new List() );
-    p.add( np );
-
-    add( "Center", p );
-
-    p = new Panel();
-    p.add( next_room = new Button ( "Next Room" ) );
-    p.add( goto_room = new Button ( "Goto Room" ) );
-    p.add( who_is_online = new Button( "Who is Online" ) );
-    p.add( page_user = new Button( "Page User" ) );
-    add( "North", p );
-
-    p = new Panel();
-    p.add( logout = new Button( "Logout" ) );
-    add( "South", p );
-
-    citadel.me.rooms.setList( newL, oldL );
-  }
-
-  public boolean action( Event e, Object o ) {
-    if( (e.target == newL) || (e.target == oldL) ) {
-      String room = getRoom();
-      if( room != null )
-       citadel.me.enterRoom( room );
-    } else if( e.target == who_is_online ) {
-      citadel.me.who_online();
-    } else if( e.target == page_user ) {
-      citadel.me.page_user();
-    } else if (e.target == next_room ) {
-      citadel.me.nextNewRoom();
-    } else if( e.target == goto_room ) {
-      citadel.me.gotoRoom( getRoom(), true );
-    } else if( e.target == logout ) {
-      citadel.me.logoff();
-    } else {
-      return super.action( e, o );
+import java.awt.event.*;
+import java.util.*;
+
+public class mainPanel extends JPanel {
+    JComboBox  jcb;
+    DefaultListModel   newLM, seenLM;
+    roomMap    rooms;
+
+    boolean    jcb_update = false;
+
+    public mainPanel() {
+       setLayout( new BorderLayout() );
+
+       JPanel  p = new JPanel();
+       p.setLayout( new BorderLayout() );
+       p.setBorder( BorderFactory.createTitledBorder( 
+                                                     BorderFactory.createEtchedBorder(), "Cmds" ) );
+
+       VertPanel       vp = new VertPanel();
+       p.add( "Center", vp );
+       JButton b;
+
+       vp.add( b = new JButton( "Next Room" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               citadel.me.enterRoom( rooms.nextNewRoom() );
+           }});
+
+       vp.add( b = new JButton( "Goto Room" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               System.out.println( "Goto Room" );
+           }});
+
+       vp.add( b = new JButton( "Page User" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+           }});
+
+       vp.add( b = new JButton( "Who Online" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+           }});
+
+       vp.add( b = new JButton( "Options" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+           }});
+
+       vp.add( b = new JButton( "Server Info" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+           }});
+
+       vp.add( b = new JButton( "Logoff" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               citadel.me.logoff();
+           } } );
+    
+       add( "West", p );
+
+       p = new JPanel();
+       p.setLayout( new BorderLayout() );
+
+       PairPanel       pp = new PairPanel();
+       jcb = new JComboBox();
+       jcb.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               if( !jcb_update )
+                   updateLists( (String)jcb.getSelectedItem() );
+           } } );
+       
+       pp.addLeft( new JLabel( "Floor: " ) );
+       pp.addRight( jcb );
+
+       p.add( "North", pp );
+
+       JPanel  ppp = new JPanel();
+       ppp.setLayout( new GridLayout( 1, 0 ) );
+       newLM = makeList( "New Rooms", ppp );
+       seenLM = makeList( "Old Rooms", ppp );
+
+       p.add( "Center", ppp );
+
+       add( "Center", p );
     }
-    return true;
-  }
-
-
-  public boolean handleEvent( Event e ) {
-    if( e.id == Event.LIST_SELECT ) {
-      if( e.target == newL ) {
-       int     i = oldL.getSelectedIndex();
-       if( i != -1 )
-         oldL.deselect( i );
-      } else {
-       int     i = newL.getSelectedIndex();
-       if( i != -1 )
-         newL.deselect( i );
-      }
+
+    public DefaultListModel makeList( String name, JPanel pp ) {
+       final JList     jl;
+       DefaultListModel        lm;
+
+       JPanel  p = new JPanel();
+       p.setLayout( new BorderLayout() );
+       p.setBorder( BorderFactory.createTitledBorder( 
+                                                     BorderFactory.createEtchedBorder(), name ) );
+
+       lm = new DefaultListModel();
+
+       p.add( "Center", new JScrollPane( jl = new JList(lm) ) );
+
+       pp.add( p );
+
+       jl.addMouseListener( new MouseAdapter() {
+           public void mouseClicked( MouseEvent e ) {
+               String  what = (String)jl.getSelectedValue();
+               if( what == null ) return;
+
+               if( e.getClickCount() == 2 )
+                   citadel.me.enterRoom( what );
+           }
+       } );
+
+       return lm;
+    } 
+
+    public void refresh() {
+       rooms = new roomMap( this );
+       citadel.me.rooms = rooms;
+       citadel.me.networkEvent( "LFLR", new CallBack() {
+           public void run( citReply r ) {
+               rooms.floors( r );
+               jcb_update = true;
+               if( jcb.getModel().getSize() > 0 )
+                   jcb.removeAllItems();
+               for( Enumeration e = rooms.f_list.elements(); e.hasMoreElements(); ) {
+                   floor       f = (floor)e.nextElement();
+                   jcb.addItem( f.name() );
+               }
+               jcb_update = false;
+               setFloor( rooms.getFloor() );
+           } } );
+
+       citadel.me.networkEvent( "LKRN", new CallBack() {
+           public void run( citReply r ) {
+               rooms.new_rooms( r );
+           } } );
+
+       citadel.me.networkEvent( "LKRO", new CallBack() {
+           public void run( citReply r ) {
+               rooms.old_rooms( r );
+
+               setFloor( rooms.getFloor() );
+               updateLists( rooms.getFloor().name );
+           } } );
     }
-    return super.handleEvent( e );
-  }
 
-  public void refresh() { 
-    citadel.me.rooms.refresh();
-  }
+    public void setFloor( String flr ) {
+       if( flr == null ) return;
+       setFloor( rooms.getFloor( flr ) );
+    }
+    
+    public void setFloor( floor f ) {
+       if( f == null ) return;
+       jcb.setSelectedItem( f.name() );
+    }
 
-  public String getRoom() {
-    String s = newL.getSelectedItem();
-    if( s == null ) s = oldL.getSelectedItem();
+    public void updateLists( String name  ) {
+       floor   f = rooms.getFloor( name );
+       if( f == null ) return;
+
+       rooms.cur_floor = f;
+       newLM.removeAllElements();
+       seenLM.removeAllElements();
+       for( Enumeration e = f.rooms.elements(); e.hasMoreElements(); ) {
+           room        rm = (room)e.nextElement();
+           if( rm.hasNew() )
+               newLM.addElement( rm.name () );
+           else
+               seenLM.addElement( rm.name() );
+       }
+    }
+}
 
-    return s;
-  }
 
-}
diff --git a/shaggy/message.java b/shaggy/message.java
new file mode 100644 (file)
index 0000000..a43f387
--- /dev/null
@@ -0,0 +1,58 @@
+import java.util.*;
+
+public class message {
+    String     blurb;
+    String     message;
+
+    public message( int count, int cur_pos, citReply r ) {
+       Vector  msg = r.listing;
+
+       String  s, from="", time="", room="", node="", rcpt="";
+       do {
+           s = (String)msg.firstElement();
+           msg.removeElementAt( 0 );
+           from = begin( from, s, "from=" );
+           time = begin( time, s, "time=" );
+           room = begin( room, s, "room=" );
+           node = begin( node, s, "hnod=" );
+           rcpt = begin( rcpt, s, "rcpt=" );
+       } while( (msg.size() > 0) && (!s.equals( "text" )) );
+
+       time = makeDate( time );
+
+       blurb = (cur_pos+1) + "/" + count + " " + time + " from " + from;
+       if( !node.equals( citadel.me.serverInfo.human_name ) )
+           blurb = blurb + " (@"+node+")";
+       if( !rcpt.equals( "" ) )
+           blurb = blurb + " to " + rcpt;
+       /*      if( !room.equals(name) )        FIXME
+               blurb = blurb + " in " + room; */
+   
+       /* this relies on the fact that we've removed
+          the header lines above.  probably a messy way 
+          to deal with references. */
+       message = r.getData(); 
+    }
+
+    public String makeDate( String time ) {
+       long    t=0;
+       try {
+           t = Long.parseLong( time );
+       } catch( NumberFormatException nfe ) {
+       };
+
+       Date    d = new Date( t*1000 );
+       return d.toLocaleString();
+    }
+
+    public String begin( String def, String data, String key ) {
+       if( data.indexOf( key ) == 0 )
+           return data.substring( key.length() );
+       return def;
+    }
+
+    public String getBlurb() { return blurb; }
+    public String getText() { return message; }
+}
+
+
index 7e47467286ac6720a502cab1254d1479a41b169c..4731706bbba08a84827302c3718a8cbde91177a5 100644 (file)
-/* messagePanel.java
- */
-
+import javax.swing.*;
 import java.awt.*;
+import java.awt.event.*;
 import java.util.*;
 
-public class messagePanel extends Panel {
-  Choice       reading;
-  Button       who_is_online, room_info;
-  Button       next_room, goto_room, page_user;
-  Button       next_msg, prev_msg, enter_msg, zap_room, back;
-  TextField    msgInfo;
-  TextArea     theMsg;
-  NamedPanel   np;
-
-  Vector       msgs;
-  int          cur_pos = -1;
-
-  String       name;
-  int          total, unread, info, flags, highest, highest_read;
-  boolean      mail, aide;
-  int          mail_num, floor;
-
-  public messagePanel() {
-    setLayout( new BorderLayout() );
-
-    VertPanel  vp = new VertPanel();
-    vp.add( reading = new Choice() );
-    reading.addItem( "Read New" );
-    reading.addItem( "Read All" );
-    reading.addItem( "Last 5" );
-    reading.select( 0 );
-
-    vp.add( next_msg = new Button( "Next Message" ) );
-    vp.add( prev_msg = new Button( "Prev Message" ) );
-    vp.add( enter_msg = new Button( "Enter Message" ) );
-    vp.add( next_room = new Button( "Next Room" ) );
-    vp.add( goto_room = new Button( "Goto Room" ) );
-    vp.add( room_info = new Button( "Room Info" ) );
-    vp.add( zap_room = new Button( "Zap Room" ) );
-    vp.add( who_is_online = new Button( "Who is Online" ) );
-    vp.add( page_user = new Button( "Page User" ) );
-    vp.add( back = new Button( "Back" ) );
-
-    add( "West", vp );
-
-    np = new NamedPanel( "Message" );
-    np.setLayout( new BorderLayout() );
-    np.add( "North", msgInfo = new TextField() );
-    np.add( "Center", theMsg = new TextArea() );
-    add( "Center", np );
-
-    /*    Panel p = new Panel();
-         add( "South", p );*/
-  }
-
-  public boolean action( Event e, Object o ) {
-    if( e.target == reading ) {
-      getMsgsPtrs();
-    } else if( e.target == page_user ) {
-      citadel.me.page_user();
-    } else if( e.target == who_is_online ) {
-      citadel.me.who_online();
-    } else if( e.target == room_info ) {
-      new displayInfo( name );
-    } else if( e.target == next_msg ) {
-      cur_pos++;
-      displayMessage();
-    } else if( e.target == prev_msg ) {
-      cur_pos--;
-      displayMessage();
-    } else if( e.target == enter_msg ) {
-      citadel.me.enterMsg( name );
-    } else if( e.target == next_room ) {
-      citadel.me.nextNewRoom();
-    } else if( e.target == goto_room ) {
-      citadel.me.gotoRoom();
-    } else if( e.target == zap_room ) {
-      new promptWindow( new zapPrompt( name ) );
-    } else if( e.target == back ) {
-      citadel.me.mainMenu();
-    }
-    return super.action( e, o );
-  }
-
-  public void refresh( citReply r ) {
-    name = r.getArg( 0 );
-    np.setLabel( name + (citadel.me.floors() ? 
-                " (" + citadel.me.rooms.getRoomsFloorName( name )+")" : "" ) );
-    total = citadel.atoi( r.getArg( 1 ) );
-    unread = citadel.atoi( r.getArg( 2 ) );
-    info = citadel.atoi( r.getArg( 3 ) );
-    flags = citadel.atoi( r.getArg( 4 ) );
-    highest = citadel.atoi( r.getArg( 5 ) );
-    highest_read = citadel.atoi( r.getArg( 6 ) );
-    mail = citadel.atoi( r.getArg( 7 ) ) != 0;
-    aide = citadel.atoi( r.getArg( 8 ) ) != 0;
-    mail_num = citadel.atoi( r.getArg( 9 ) ); 
-    floor = citadel.atoi( r.getArg( 10 ) );
-
-    msgInfo.setText( "" );
-    theMsg.setText( "" );
-
-    if( info != 0 ) new displayInfo( name );
-    getMsgsPtrs();
-  }
-
-  public void getMsgsPtrs() {
-    msgs = null;
-    String     which = "new";
-    if( reading.getSelectedIndex() == 1 ) which = "all";
-    else if( reading.getSelectedIndex() == 2 ) which = "last|5";
-    citReply   r = citadel.me.getReply( "MSGS " + which );
-    if( !r.error() ) {
-      msgs = r.listing;
-      cur_pos = 0;
+public class messagePanel extends JPanel {
+    roomFrame  parent;
+    JTextField blurb;
+    JTextArea  message;
+
+    roomInfo   ri;
+    Vector     msgs;
+    int                cur_pos = 0;
+
+    JComboBox  jcb;
+    JButton    next_msg, prev_msg;
+    boolean    ignore_box = false;
+
+    public messagePanel( final roomFrame parent ) {
+       this.parent = parent;
+
+       setLayout( new BorderLayout() );
+       
+       JPanel  p = new JPanel();
+       p.setLayout( new BorderLayout() );
+       p.setBorder( BorderFactory.createTitledBorder( 
+                 BorderFactory.createEtchedBorder(), "Cmds" ) );
+
+       VertPanel       vp = new VertPanel();
+       p.add( "Center", vp );
+       JButton         b;
+
+       vp.add( b = new JButton( "Next Room" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               citadel.me.enterRoom( citadel.me.rooms.nextNewRoom() );
+           } } );
+
+       vp.add( b = new JButton( "Enter Message" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               parent.enterMessage();
+           } } );
+
+       vp.add( b = new JButton( "Zap Room" ) );
+       b.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               System.out.println( "Zap room" );
+           } } );
+
+
+       jcb = new JComboBox();
+       jcb.addItem( "Read New" );
+       jcb.addItem( "Read All" );
+       jcb.addItem( "Last 5" );
+       jcb.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               if( !ignore_box )
+                   refresh();
+           }
+       } );
+
+       vp.add( jcb );
+
+       add( "West", p );
+
+       p = new JPanel();
+
+       p.add( prev_msg = new JButton( "Prev Message" ) );
+       prev_msg.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               cur_pos--;
+               displayMessage();
+           } } );
+
+       p.add( next_msg = new JButton( "Next Message" ) );
+       next_msg.addActionListener( new ActionListener() {
+           public void actionPerformed( ActionEvent e ) {
+               cur_pos++;
+               displayMessage();
+           } } );
+
+
+       add( "South", p );
+
+
+       p = new JPanel();
+       p.setLayout( new BorderLayout() );
+
+       p.add( "North", blurb = new JTextField() );
+       blurb.setEditable( false );
+       p.add( "Center", new JScrollPane( message = new JTextArea() )  );
+       message.setEditable( false );
+       add( "Center", p );
     }
-    displayMessage();
-  }
-
-  public void displayMessage() {
-    if( msgs == null) { 
-      msgInfo.setText( "<no messages>" );
-      theMsg.setText( "" );
-      return;
+
+    public void refresh() {
+       refresh( ri );
     }
 
-    if( cur_pos <= 0 ) {
-      cur_pos = 0;
-      prev_msg.disable();
-    } else
-      prev_msg.enable();
-
-    if( cur_pos >= msgs.size()-1 ) {
-      cur_pos = msgs.size()-1;
-      next_msg.disable();
-    } else
-      next_msg.enable();
-
-    String     num = (String)msgs.elementAt( cur_pos );
-
-    citReply   r = citadel.me.getReply( "MSG0 " + num + "|0" );
-    if( r.error() ) {
-      msgInfo.setText( "<error>" );
-      theMsg.setText( r.getArg(0) );
-      return;
+    public void refresh( roomInfo ri ) {
+       this.ri = ri;
+
+       cur_pos = 0;
+       msgs = new Vector();
+
+       /* add new, all, last, etc. */
+
+       String  cmd = "new";
+       switch( jcb.getSelectedIndex() ) {
+       case    0:      // new
+           break;
+       case 1:         // All
+           cmd = "all";
+           break;
+       case 2:         // Last - 5
+           cmd = "last|5";
+           break;
+       }
+
+       next_msg.setEnabled( false );
+       prev_msg.setEnabled( false );
+
+       citadel.me.networkEvent( "MSGS " + cmd, new CallBack() {
+           public void run( citReply   r ) {
+               msgs = r.listing;
+               displayMessage();
+           } } );
     }
 
-    Vector     msg = r.listing;
-    String     s, from="", time="", room="", node="", rcpt="";
-    do {
-      s = (String)msg.firstElement();
-      msg.removeElementAt( 0 );
-      from = begin( from, s, "from=" );
-      time = begin( time, s, "time=" );
-      room = begin( room, s, "room=" );
-      node = begin( node, s, "hnod=" );
-      rcpt = begin( rcpt, s, "rcpt=" );
-    } while( (msg.size() > 0) && (!s.equals( "text" )) );
-
-    time = makeDate( time );
-
-    String     sum = (cur_pos+1) + "/" + msgs.size() + " " + time + " from " + from;
-    if( !node.equals( citadel.me.serverInfo.human_name ) )
-      sum = sum + " (@"+node+")";
-    if( !rcpt.equals( "" ) )
-      sum = sum + " to " + rcpt;
-    if( !room.equals(name) )
-      sum = sum + " in " + room;
-   
-    msgInfo.setText( sum );
-    theMsg.setText( r.getData() ); /* this relies on the fact that we've removed the header lines above.  probably a messy way to deal with references. */
-
-    int        n = citadel.atoi( num );
-    if( n > highest_read ) {
-      highest_read = n;
-      citadel.me.getReply( "SLRP " + num );
+    public void displayMessage() {
+       if( (msgs == null) || (msgs.size() == 0) ) {
+           blurb.setText( "" );
+           message.setText( "<no messages>" );
+           return;
+       }
+
+       if( cur_pos <= 0 ) {
+           cur_pos = 0;
+           prev_msg.setEnabled( false );
+       } else
+           prev_msg.setEnabled( true );
+
+       if( cur_pos >= msgs.size()-1 ) {
+           cur_pos = msgs.size()-1;
+           next_msg.setEnabled( false );
+       } else
+           next_msg.setEnabled( true );
+
+       final String    num = (String)msgs.elementAt( cur_pos );
+
+       citadel.me.networkEvent( "MSG0 " + num + "|0", new CallBack() {
+           public void run( citReply r ) {
+               if( r.error() ) {
+                   blurb.setText( "<error>" );
+                   message.setText( r.getArg(0) );
+               } else {
+                   message msg = new message( msgs.size(), cur_pos, r );
+                   blurb.setText( msg.getBlurb() );
+                   message.setText( msg.getText() );
+                   int n = citadel.atoi( num );
+                   if( n  > ri.highest_read ) {
+                       citadel.me.networkEvent( "SLRP " + num );
+                       ri.highest_read = n;
+                   }
+               }
+           }
+       } );
     }
-  }
-
-  public String makeDate( String time ) {
-    long       t=0;
-    try {
-      t = Long.parseLong( time );
-    } catch( NumberFormatException nfe ) {
-    };
-
-    Date       d = new Date( t*1000 );
-    return d.toLocaleString();
-  }
-
-  public String begin( String def, String data, String key ) {
-    if( data.indexOf( key ) == 0 )
-      return data.substring( key.length() );
-    return def;
-  }
-                                                 
 }
index d6ded6dadc9be2def934bcf199353b73a8ea1eed..22f9ea9b295dfbaf6e5b01524472d49528746d70 100644 (file)
-/* net.java
- * chilly@alumni.psu.edu
- *
- * Object to talk the network talk with cit/ux server.
- * Dispatches events.
- */
-
+import javax.swing.*;
 import java.io.*;
 import java.net.*;
+import java.util.*;
 
-public class net {
-  Socket               theServer;
-
-  DataInputStream      in;
-  DataOutputStream     out;
-
-  public net() {
-    theServer = null;
-  }
-
-  private void println( String s ) {
-    System.out.println( ">" + s );
-    try {
-      if( theServer != null )
-       out.writeBytes( s + "\n" );
-    } catch( IOException ioe ) {
-      citadel.me.lostNetwork( "Connection dropped (write)" );
-      if( theServer != null ) {
-       try { theServer.close(); theServer = null; }
-       catch( Exception e ) {};
-      }
-    }
-  }
-
-  private String readLine( ) {
-    try {
-      if( theServer != null ) {
-       String s = in.readLine();
-       System.out.println( "<" + s );
-       return s;
-      }
-    } catch( IOException ioe ) {
-      citadel.me.lostNetwork( "Network error: reead" );
-      if( theServer != null ) {
-       try { theServer.close(); theServer = null; }
-       catch( Exception e ) {};
-      }
-    }
-    return null;
-  }
+public class net implements Runnable {
+    Queue              theQueue;
 
-  public boolean connect( ) {
-    return connect( "127.0.0.1" );
-  }
+    Socket             theSocket;
+    DataInputStream    in;
+    DataOutputStream   out;
 
-  public boolean connect( String serverName ) {
-    return connect( serverName, 504 );
-  }
+    boolean            done;
 
-  public boolean connect( String serverName, int port ) {
-    try {
-      theServer = new Socket( serverName, port );
+    public net() {
+       theQueue = new Queue();
+    }
 
-      in = new DataInputStream( theServer.getInputStream() );
-      out = new DataOutputStream( theServer.getOutputStream() );
+    private void println( String s ) {
+       System.out.println( ">" + s );
+       try {
+           if( theSocket != null )
+               out.writeBytes( s + "\n" );
+       } catch( IOException ioe ) {
+           citadel.me.lostNetwork( "Connection dropped (write)" );
+           if( theSocket != null ) {
+               try { theSocket.close(); }
+               catch( Exception e ) {};
+           }
+           theSocket = null;
+       }
+    }
 
-    } catch( IOException ioe ) {
-      citadel.me.lostNetwork( "Couldn't connect to server" );
-      return false;
+    private String readLine( ) {
+       try {
+           if( theSocket != null ) {
+               String s = in.readLine();
+               System.out.println( "<" + s );
+               return s;
+           }
+       } catch( IOException ioe ) {
+           citadel.me.lostNetwork( "Network error: read" );
+           if( theSocket != null ) {
+               try { theSocket.close(); }
+               catch( Exception e ) {};
+           }
+           theSocket = null;
+       }
+       return null;
     }
 
-    citReply rep = getReply();
+    public String getArch() {
+       try {
+           Properties  p = System.getProperties();
+           return p.get( "os.name" ) + "/" + p.get( "os.arch" );
+       } catch( SecurityException se ) {
+           return "<unknown>";
+       }
+    }
 
-    if( rep.ok() ) return true;
-    return false;
-  }
+    public String getHostName() {
+       try {
+           InetAddress me = InetAddress.getLocalHost();
+           return me.getHostName();
+       } catch( Exception e ) {
+           return "dunno";
+       }
+    }
 
-  public citReply getReply() {
-    return getReply( (String)null, (String)null );
-  }
+    public void run() {
+       String  server = citadel.me.server;
+       int             port = citadel.me.port;
+       boolean         proxy = false;
+
+       done = false;
+       try {
+           if( proxy )
+               proxy = !server.equals( "127.0.0.1" );
+         
+           if( proxy )
+               theSocket = new Socket( "armstrong.cac.psu.edu", 13579 );
+           else
+               theSocket = new Socket( server, port );
+           
+
+           in = new DataInputStream( theSocket.getInputStream() );
+           out = new DataOutputStream( theSocket.getOutputStream() );
+       } catch( IOException ioe ) {
+           citadel.me.lostNetwork( "Couldn't connect to server." );
+           return;
+       }
+       
+       if( proxy ) {
+           println( server );
+           println( ""+port );
+       }
+
+       citReply        rep = getReply();
+       if( !rep.ok() ) {
+           citadel.me.lostNetwork( "Couldn't connect: " + rep.line );
+           return;
+       }
+
+       getReply( "IDEN 0|7|" + citadel.VERSION + "|" + citadel.NAME + " " +
+                 citadel.VERSION + " (" + getArch() + ")|" + getHostName() );
+
+       MsgCmd  m;
+       while( ((m = (MsgCmd)theQueue.get()) != null) && !done ) {
+           citReply    r = getReply( m.cmd, m.data );
+           m.setReply( r );
+           SwingUtilities.invokeLater( m );
+       }
+
+       try {
+           theSocket.close();
+       } catch( IOException ioe ) {
+       }
+       if( !done )
+           citadel.me.lostNetwork( "Connection closed." );
 
-  public citReply getReply( String cmd ) {
-    return getReply( cmd, (String)null );
-  }
+    }
 
-  public citReply getReply( String cmd, String data ) {
-    if( cmd != null ) println( cmd );
+    public void done() {
+       done = true;
+       theQueue.append( null );
+    }
 
-    citReply r = new citReply( readLine() );
-    if( r.listingFollows() ) {
-      while( r.addData( readLine() ) ) ;
+    public void append( MsgCmd m ) {
+       theQueue.append( m );
     }
 
-    if( r.sendListing() ) {
-      if( data != null )
-       println( data );
-      println( "000" );
+    public citReply getReply() {
+       return getReply( (String)null, (String)null );
     }
 
-    if( r.expressMessage() )
-      citadel.me.expressMsg();
+    public citReply getReply( String cmd ) {
+       return getReply( cmd, (String)null );
+    }
 
-    return r;
-  }
-}
+    public citReply getReply( String cmd, String data ) {
+       if( cmd != null ) println( cmd );
 
+       citReply r = new citReply( readLine() );
+       if( r.listingFollows() ) {
+           while( r.addData( readLine() ) ) ;
+       }
 
+       if( r.sendListing() ) {
+           if( data != null )
+               println( data );
+           println( "000" );
+       }
 
+       if( r.expressMessage() )
+           citadel.me.expressMsg();
 
+       return r;
+    }
+}
diff --git a/shaggy/pageWindow.java b/shaggy/pageWindow.java
deleted file mode 100644 (file)
index ce7da0b..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/* pageWindow.java
- */
-
-import java.awt.*;
-
-public class pageWindow extends Frame {
-  String       user;
-  Choice       who;
-  TextComponent        msg;
-  Button       send, cancel;
-  boolean      multi_line;
-
-  public pageWindow( String user ) {
-    this.user = user;
-
-    setTitle( "Page a user" );
-    setLayout( new BorderLayout() );
-
-    PairPanel  pp = new PairPanel();
-    pp.addLeft( new Label( "Send message to:" ) );
-    pp.addRight( who = new Choice() );
-
-    add( "North", pp );
-
-    NamedPanel np = new NamedPanel( "Message" );
-    np.setLayout( new BorderLayout() );
-
-    multi_line = citadel.me.serverInfo.page_level == 1;
-    if( multi_line )
-      msg = new        TextArea();
-    else 
-      msg = new TextField();
-
-    np.add( "Center", msg );
-
-    add( "Center", np );
-
-    Panel p = new Panel();
-    p.add( send = new Button( "Send" ) );
-    p.add( cancel = new Button( "Cancel" ) );
-    add( "South", p );
-
-    if( user != null )
-      who.addItem( user );
-    else {
-      citReply r = citadel.me.getReply( "RWHO" );
-      int      i=0, which=0;
-      String   s;
-      while( (s=r.getLine( i++ )) != null ) {
-       String u = getUser(s);
-       if( u.equalsIgnoreCase( user ) ) which = i-1;
-       who.addItem( u );
-      }
-
-      who.select( which );
-    }
-
-    resize( 300, multi_line?300:150 );
-    show();
-  }
-
-  public String getUser( String s ) {
-    int        i = s.indexOf( '|' )+1;
-    int j = s.indexOf( '|', i );
-    return s.substring( i, j );
-  }
-
-  public boolean handleEvent( Event e ) {
-    if( e.id == Event.WINDOW_DESTROY )
-      dispose();
-    return super.handleEvent( e );
-  }
-
-  public boolean action( Event e, Object o ) {
-    if( (e.target == send) || (!multi_line && (e.target == msg)) ) {
-      String user = who.getSelectedItem();
-      String m = msg.getText();
-      if( m.length() > 0 ) {
-       if( multi_line ) {
-         citReply      r = citadel.me.getReply( "SEXP " + user + "|-", m + "\n"  );
-         if( r.error() )
-           citadel.me.error( r );
-       } else
-         citadel.me.getReply( "SEXP " + user + "|" + m );
-      }
-      dispose();
-    } else if( e.target == cancel )
-      dispose();
-    return super.action( e, o );
-  }
-}
diff --git a/shaggy/room.java b/shaggy/room.java
new file mode 100644 (file)
index 0000000..e56ae43
--- /dev/null
@@ -0,0 +1,42 @@
+import java.util.*;
+
+public class room {
+  String       name, fname;
+  int          flags, floor, order;
+  boolean      nmsgs;
+
+  public room( String l ) {
+    nmsgs = false;
+
+    int        i = l.indexOf( '|' );
+    name = l.substring( 0, i ); 
+
+    int        j = l.indexOf( '|', ++i );
+    flags = citadel.atoi( l.substring( i, j ) );
+
+    i = l.indexOf( '|', ++j );
+    floor = citadel.atoi( fname = l.substring( j, i ) );
+    order = citadel.atoi( l.substring( i+1 ) );
+
+    /*    System.out.println( "room name: " + name );
+    System.out.println( "flags    : " + flags );
+    System.out.println( "floor    : " + floor );
+    System.out.println( "order    : " + order );*/
+  }
+
+  public boolean hasNew() {
+    return nmsgs;
+  }
+
+  public void setNew() {
+    setNew( true );
+  }
+
+  public void setNew( boolean val) {
+    nmsgs = val;
+  }
+
+  public String name() {
+    return name;
+  }
+}
diff --git a/shaggy/roomCmp.java b/shaggy/roomCmp.java
new file mode 100644 (file)
index 0000000..ba9cff7
--- /dev/null
@@ -0,0 +1,13 @@
+class roomCmp extends sorter {
+  public int cmp( Object o1, Object o2 ) {
+    room       r1 = (room)o1;
+    room       r2 = (room)o2;
+
+    /* Do I want to sort on floors here, even if users don't use it? */
+
+    if( r1.order < r2.order ) return -1;
+    else if( r1.order == r2.order )
+      return r1.name().compareTo( r2.name() );
+    return 1;
+  }
+}
diff --git a/shaggy/roomFrame.java b/shaggy/roomFrame.java
new file mode 100644 (file)
index 0000000..9978c13
--- /dev/null
@@ -0,0 +1,56 @@
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class roomFrame extends JFrame {
+    CardLayout         cdLayout;
+    Container          c;
+
+    roomInfo           ri;
+
+    messagePanel       mp;
+    enterPanel         ep;
+
+    public roomFrame() {
+       ri = null;
+       setTitle( "Title of this window" );
+
+       c = getContentPane();
+
+       c.setLayout( cdLayout = new CardLayout() );
+       c.add( "Messages", mp = new messagePanel(this) );
+       c.add( "Compose", ep = new enterPanel(this) );
+
+       addWindowListener( new WindowAdapter() {
+           public void windowClosing( WindowEvent e ) {
+               citadel.me.rf = null;
+               dispose();
+           }
+       } );
+
+       this.pack();
+       this.show();
+    }
+
+    public void setRoom( roomInfo ri ) {
+       this.ri = ri;
+
+       String  title = ri.name;
+       if( citadel.me.floors() ) {
+           title = title + " (" + citadel.me.rooms.getFloor( ri.rm ).name + ")";
+       }
+
+       setTitle( title );
+       cdLayout.show( c, "Messages" );
+       mp.refresh( ri );
+    }
+
+    public void showRoom() {
+       cdLayout.show( c, "Messages" );
+    }
+
+    public void enterMessage() {
+       cdLayout.show( c, "Compose" );
+       ep.refresh( ri );
+    }
+}
diff --git a/shaggy/roomInfo.java b/shaggy/roomInfo.java
new file mode 100644 (file)
index 0000000..1086033
--- /dev/null
@@ -0,0 +1,22 @@
+public class roomInfo {
+    String     name;
+    int                total, unread, info, flags, highest, highest_read;
+    boolean    mail, aide;
+    int                mail_num, floor;
+    room       rm;
+
+    public roomInfo( room rm, citReply r ) {
+       this.rm = rm;
+       name = r.getArg( 0 );
+       total = citadel.atoi( r.getArg( 1 ) );
+       unread = citadel.atoi( r.getArg( 2 ) );
+       info = citadel.atoi( r.getArg( 3 ) );
+       flags = citadel.atoi( r.getArg( 4 ) );
+       highest = citadel.atoi( r.getArg( 5 ) );
+       highest_read = citadel.atoi( r.getArg( 6 ) );
+       mail = citadel.atoi( r.getArg( 7 ) ) != 0;
+       aide = citadel.atoi( r.getArg( 8 ) ) != 0;
+       mail_num = citadel.atoi( r.getArg( 9 ) ); 
+       floor = citadel.atoi( r.getArg( 10 ) );
+    }
+}
index f034293f13e725da29be8ab2cc56907291fc6ddf..0d2d7b9cbbca0eea4cb2dd5a39d0f27a99732946 100644 (file)
-/* roomMap.java
- * Keeps track of floors and rooms and all that stuff.
- */
-
 import java.util.*;
-import java.awt.List;
 
 public class roomMap {
+  Vector       f_list;
   Hashtable    floors, rooms;
-  SortedVector nrm, srm;
-  Vector       floor_list;
-  int          cur_floor;
-
-  List         nrmL, srmL;
-  boolean      refreshed;
-
-  public roomMap( ) {
-    nrmL = null;
-    srmL = null;
 
-    nrm = new SortedVector( new roomCmp() );
-    srm = new SortedVector( new roomCmp() );
-    floors = null;
-    rooms = null;
-
-    refreshed = false;
-  }
+  floor                cur_floor;
+  mainPanel    mp;
 
-  public void loadFloorInfo() {
+  public roomMap( mainPanel mp ) {
+    f_list = new Vector();
     floors = new Hashtable();
-    floor_list = new Vector();
-    cur_floor = 0;
-    citReply   r = citadel.me.getReply( "LFLR" );
+    rooms = new Hashtable();
+    this.mp = mp;
+  }
 
-    if( r.error() ) return;
+  public void floors( citReply r ) {
+    int                i = 0;
+    String     line;
 
-    String     l;
-    for( int i = 0; (l = r.getLine( i )) != null; i++ ) {
-      floor    f = new floor( l );
-      floors.put( f.num(), f );
-      floor_list.addElement( f );
+    floors = new Hashtable();
+    
+    while( (line = r.getLine( i++ ) ) != null ) {
+      floor    f = new floor( line );
+      floors.put( f.num, f );
+      floors.put( f.name, f );
+      f_list.addElement( f );
     }
   }
 
-  public void setList( List n, List s ) {
-    nrmL = n;
-    srmL = s;
-    refreshed = false;
-  }
+  public void new_rooms( citReply rep ) {
+    int                i = 0;
+    String     line;
 
-  public void clear() {
-    floors = null;
-    nrm = null;
-    srm = null;
-    refreshed = false;
+    while( (line = rep.getLine( i++ ) ) != null ) {
+      room     r, rr = new room( line );
+      r = (room)rooms.get( rr.name() );
+      if( r == null ) {
+       rr.setNew();
+       rooms.put( rr.name, rr );
+       addToFloor( rr );
+      } else 
+       r.setNew();
+    }
   }
 
-  public void refresh() {
-    if( refreshed ) return;
-    if( (nrmL == null) || (srmL == null) ) return;
-    if( floors == null ) loadFloorInfo();
+  public void old_rooms( citReply rep ) {
+    int                i = 0;
+    String     line;
 
-    if( floors != null ) {
-      for( Enumeration e = floor_list.elements(); e.hasMoreElements(); ) {
-       floor   f = (floor)e.nextElement();
-       f.rooms = new SortedVector( new roomCmp() );
-      }
+    while( (line = rep.getLine( i++ )) != null ) {
+      room     r = new room( line );
+      rooms.put( r.name(), r );
+      addToFloor( r );
     }
-
-    rooms = new Hashtable();
-
-    nrm = new SortedVector( new roomCmp() );
-    nrmL.clear(); 
-    parseRooms( nrm, nrmL, citadel.me.getReply( "LKRN" ), true );
-
-    srm = new SortedVector( new roomCmp() );
-    srmL.clear();
-    parseRooms( srm, srmL, citadel.me.getReply( "LKRO" ), false );
-    refreshed = true;
   }
-       
-  public void parseRooms( SortedVector v, List l, citReply r, boolean nmsgs ) {
-    int                i=0;
-    String     s;
 
-    while( (s = r.getLine( i++) ) != null ) {
-      room rm = new room( s );
-      rm.setNew( nmsgs );
-      if( rm.valid() ) {
-       rooms.put( rm.name(), rm );
-       addRoomToFloor( rm );
-       v.addElement( rm );
-      }
-    }
-    for( Enumeration e=v.elements(); e.hasMoreElements(); ) {
-      room rm = (room)e.nextElement();
-      l.addItem( rm.name() );
-    }
+  public void addToFloor( room r ) {
+    floor      f = (floor)floors.get( r.fname );
+    if( f != null )
+      f.addRoom( r );
   }
 
-  public void addRoomToFloor( room theRoom ) {
-    if( floors == null ) return;
+  public floor nextFloor() {
+    int        c = f_list.indexOf( cur_floor );
+    c++;
 
-    floor f = getFloor( theRoom.getFloor() );
-    if( f == null ) return;
-    f.addRoom( theRoom );
+    try {
+      cur_floor = (floor)f_list.elementAt( c );
+    } catch( Exception e ) {
+      cur_floor = (floor)f_list.firstElement();
+    }
+
+    setFloor( cur_floor );
+    return cur_floor;
   }
+    
+  public floor getFloor() {
+    if( cur_floor == null ) cur_floor = (floor)f_list.firstElement();
 
-  public floor getFloor( int i ) {
-    return getFloor( ""+i );
+    return cur_floor;
   }
 
   public floor getFloor( String name ) {
     return (floor)floors.get( name );
   }
 
-  public room getRoom( String name ) {
-    return (room)rooms.get( name );
+  public floor getFloor( room rm ) {
+    return getFloor( rm.fname );
   }
 
-  public String getRoomsFloorName( String name ) {
-    room       rm = getRoom( name );
-    if( rm == null ) return "<bad room>";
-    floor      f = getFloor( rm.getFloor() );
-    if( f == null ) return "<bad floor>";
-    return f.name();
+  public void setFloor( floor f ) {
+    cur_floor = f;
+    mp.setFloor( f );
+    mp.updateLists( f.name() );
   }
 
-  public String nextNewRoom() {
-    try {
-      if( nrm.size() <= 1 ) refreshed = false;
-
-      if( citadel.me.floors() ) {
-       String  name = null;
-       while( name == null ) {
-         floor f = (floor)floor_list.elementAt( cur_floor );
-         name = f.nextNewRoom();
-         if( name == null ) cur_floor++;
-       }
-       return name;
-      }
-
-      /* no floors */
-      return ((room)nrm.firstElement()).name();
+  public room nextNewRoom() {
+    floor      c = getFloor();
 
-    } catch( Exception nsee ) {
-      cur_floor = 0;
-      refreshed = false;
-      return "_BASEROOM_";
-    }
-  }
-
-  public void visited( String rm ) {
-    if( (nrmL == null) || (srmL == null) ) return;
-    for( int i = 0; i < nrmL.countItems(); i++ ) {
-      if( rm.equals( nrmL.getItem( i ) ) ) {
-       nrmL.delItem( i );
-       srmL.addItem( rm );
+    do {
+      for( Enumeration e = getFloor().rooms.elements(); e.hasMoreElements(); ) {
+       room    r = (room)e.nextElement();
+       if( r.hasNew() ) return r;
       }
-    }
-
-    room r = getRoom( rm );
-    if( r == null ) return;
-
-    r.setNew( false );
-    if( nrm.removeElement( r ) != -1 )
-      srm.addElement( r );
-  }
-}
-
-class roomCmp extends sorter {
-  public int cmp( Object o1, Object o2 ) {
-    room       r1 = (room)o1;
-    room       r2 = (room)o2;
+      nextFloor();
+    } while( c != getFloor() );
 
-    /* Do I want to sort on floors here, even if users don't use it? */
+    System.out.println( "No more new rooms... refreshing list" );
 
-    if( r1.order < r2.order ) return -1;
-    else if( r1.order == r2.order )
-      return r1.name().compareTo( r2.name() );
-    return 1;
-  }
-}
-
-class room {
-  String       name;
-  int          flags, floor, order;
-  boolean      nmsgs;
-
-  public room( String l ) {
-    nmsgs = false;
-
-    int        i = l.indexOf( '|' );
-    name = l.substring( 0, i ); 
-
-    int        j = l.indexOf( '|', ++i );
-    flags = citadel.atoi( l.substring( i, j ) );
-
-    i = l.indexOf( '|', ++j );
-    floor = citadel.atoi( l.substring( j, i ) );
-    order = citadel.atoi( l.substring( i+1 ) );
-
-    /*    System.out.println( "room name: " + name );
-    System.out.println( "flags    : " + flags );
-    System.out.println( "floor    : " + floor );
-    System.out.println( "order    : " + order );*/
-  }
-
-  public String name() {
-    return name;
-  }
-
-  public int getFloor() {
-    return floor;
-  }
-
-  public boolean is( String name ) {
-    return this.name.equalsIgnoreCase( name );
-  }
+    citadel.me.networkEvent( "LKRN", new CallBack() {
+      public void run( citReply r ) {
+       new_rooms( r );
+       room    rm = getRoom( "Lobby" );
+       setFloor( getFloor( rm ) );
+       
+      } } );
 
-  public boolean valid() {
-    return true;
-  }
+    room       r = getRoom( "Lobby" );
+    setFloor( getFloor( r ) );
 
-  public void  setNew( boolean nmsgs ) {
-    this.nmsgs = nmsgs;
+    return r;
   }
 
-  public boolean getNew() {
-    return nmsgs;
+  public room getRoom( String name ) {
+    return (room)rooms.get(name);
   }
+    
 }
 
-class floor {
-  String       name, num;
-  int          number, ref_count;
-  SortedVector rooms;
 
-  public floor( String l ) {
-    rooms = new SortedVector( new roomCmp() );
-
-    int        i = l.indexOf( '|' );
-    num = l.substring( 0, i );
-    number = citadel.atoi( num );
-
-    int        j = l.indexOf( '|', ++i );
-    name = l.substring( i, j );
-
-    ref_count = citadel.atoi( l.substring( j+1 ) );
-
-    /*    System.out.println( "floor name: " + name );
-    System.out.println( "number    : " + number );
-    System.out.println( "ref_count : " + ref_count );*/
-  }
-
-  public String num() {
-    return num;
-  }
-
-  public int number() {
-    return number;
-  }
-
-  public String name() {
-    return name;
-  }
-
-  public void addRoom( room r ) {
-    if( rooms == null ) rooms = new SortedVector( new roomCmp() );
-    if( !rooms.isElement( r ) )
-      rooms.addElement( r );
-  }
-
-  public String nextNewRoom() {
-    for( Enumeration e = rooms.elements(); e.hasMoreElements(); ) {
-      room     r = (room)e.nextElement();
-      if( r.getNew() ) return r.name();
-    }
-    return null;
-  }
-}
diff --git a/shaggy/roomPassPrompt.java b/shaggy/roomPassPrompt.java
deleted file mode 100644 (file)
index 216af0d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* roomPassPrompt.java
- * when a room has a password
- */
-
-public class roomPassPrompt extends promptCmd {
-  String       room;
-
-  public roomPassPrompt( String room ) {
-    this.room = room;
-  }
-
-  public int getType() { return promptWindow.ONE_FIELD; }
-  public String getTitle() { return "Password for \"" + room + "\""; }
-  public String getPrompt() { return room+ "'s password"; }
-
-  public String firstPrompt() { return  "Password:"; };
-  public boolean firstEcho() { return false; }
-
-  public void one_field( String pass ) {
-    citadel.me.enterRoom( room, pass );
-  }
-}
index 997f019136ee8c6144abc9b1956c28b544062bfa..f740b91f6815b243e56ea07316c260f6d3d675fd 100644 (file)
@@ -1,7 +1,6 @@
-/* sorted.java
- * interface for use in SortedVector
- */
-
-public abstract class sorter {
-  public abstract int cmp( Object o1, Object o2 );     /* -1, 0 (equal), 1 */
+public class sorter {
+  public int cmp( Object o1, Object o2 ) {
+       String  s1 = (String)o1, s2 = (String)o2;
+       return s1.compareTo( s2 );
+       }
 }
diff --git a/shaggy/whoWindow.java b/shaggy/whoWindow.java
deleted file mode 100644 (file)
index a70d50c..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* whoWindow.java
- * Who is online window
- */
-
-import java.awt.*;
-import java.util.Vector;
-
-public class whoWindow extends Frame {
-  Button       refresh, page, close;
-  List         users;
-  Vector       list;
-
-  public whoWindow() {
-    super( "Citadel: Who is online" );
-
-    NamedPanel np = new NamedPanel( "Who is currently online" );
-    np.setLayout( new BorderLayout() );
-    np.add( "Center", users = new List() );
-    users.setFont( new Font( "Courier", Font.PLAIN, 12 ) );
-
-    Panel      p = new Panel();
-    p.add( refresh = new Button( "Refresh" ) );
-    p.add( page = new Button( "Page" ) );
-    p.add( close = new Button( "Close" ) );
-
-    add( "Center", np );
-    add( "South", p );
-
-    refresh();
-
-    resize( 400, 300 );
-    show();
-  }
-
-  public boolean handleEvent( Event e ) {
-    if( e.id == Event.WINDOW_DESTROY ) {
-      dispose();
-      citadel.me.wo = null;
-    }
-    return super.handleEvent( e );
-  }
-
-  public boolean action( Event e, Object o ) {
-    if( e.target == close ) {
-      dispose();
-      citadel.me.wo = null;
-    } else if( (e.target == page) || (e.target == users) ) {
-      int      i = users.getSelectedIndex();
-      try {
-       String  user = (String)list.elementAt( i );
-       citadel.me.page_user( user );
-      } catch( Exception exp ) {}
-    } else if( e.target == refresh ) {
-      refresh();
-    }
-    return super.action( e, o );
-  }
-
-  public void refresh() {
-    list = new Vector();
-    users.clear();
-
-    citReply   r = citadel.me.getReply( "RWHO" );
-    int                i = 0;
-    String     s;
-    while( (s = r.getLine( i++ )) != null ) {
-      int      j = s.indexOf( '|' ) + 1;
-      int      k = s.indexOf( '|', j );
-      int      l = s.indexOf( '|', k + 1 );
-      String   user = s.substring( j, k );
-      String   room = s.substring( k+1, l );
-      list.addElement( user );
-      users.addItem( pad( user, room ) );
-    }
-  }
-
-  public String pad( String u, String r ) {
-    StringBuffer       s = new StringBuffer( u );
-    while( s.length() < 30 )
-      s.append( ' ' );
-    s.append( r );
-    return s.toString();
-  }
-}
diff --git a/shaggy/zapPrompt.java b/shaggy/zapPrompt.java
deleted file mode 100644 (file)
index cadc41c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* zapPrompt.java
- * yes/no do you really want to zap this room?
- */
-
-public class zapPrompt extends promptCmd {
-  String       name;
-
-  public zapPrompt( String name ) {
-    this.name = name;
-  }
-
-  public int getType() { return promptWindow.YES_NO; }
-  public String getPrompt() { 
-    return "Are you sure you want to zap " + name + "?";
-  }
-
-  public String getTitle() {
-    return "Zap Confirmation";
-  }
-
-  public void yes() {
-    citReply   r = citadel.me.getReply( "FORG" );
-    if( r.ok() )
-      citadel.me.nextNewRoom();
-  }
-}