- can log off (shows goodbye, and in application lets you connect to a
different server)
-* can't recieve express messages (GEXP style, will get all messages that
+- can recieve express messages (GEXP style, will get all messages that
are there.
-* can't send and "reply" to express messages, uses either single or multi
+- can send and "reply" to express messages, uses either single or multi
depending on server support.
-* no who is online
+- 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
- forward and reverse
- enter messages in room (only type 0)
- handles Mail room
-* doesn't say anything about having mail or going there first, just lists
- Mail in the "new" list.
+- checks for mail and opens mail room automatically if you have any new
* No reply button when in mail room.
- can see "next" and "prev" message. (goes through the MSGS list which it
gets when you first enter the room) no way to jump around (yet?).
better personally, but hey, that's me.
* can't view room info
-everything else isn't done.
+everything else isn't done.
\ No newline at end of file
+import javax.swing.JFrame;
+import java.util.*;
public class citadel {
public final static String NAME="Shaggy", VERSION="0.1";
String server;
int port;
+ Vector windows;
citGui cg;
net theNet;
theNet = new net();
serverInfo = null;
rf = null;
+ windows = new Vector();
}
public void showHostBrowser() {
}
public void expressMsg() {
- System.out.println( "got an express message!" );
+ networkEvent( "GEXP", new CallBack() {
+ public void run( citReply r ) {
+ if( !r.error() )
+ new expressWindow(r);
+ if( atoi( r.getArg( 0 ) ) != 0 )
+ expressMsg();
+ } } );
}
public void gotoRoom( String name ) {
networkEvent( cmd, null, cb );
}
+ public void networkEvent( String cmd, String data ) {
+ networkEvent( cmd, data, null );
+ }
+
public void networkEvent( String cmd, String data, CallBack cb ) {
theNet.append( new MsgCmd( cmd, data, cb ) );
}
if( rf != null )
rf.dispose();
rf = null;
+ for( Enumeration e = windows.elements(); e.hasMoreElements(); ) {
+ JFrame f = (JFrame)e.nextElement();
+ f.dispose();
+ }
+
cg.showLogoffPanel();
networkEvent( "QUIT", new CallBack() {
public void run( citReply r ) {
} } );
}
+ public void registerWindow( JFrame win ) {
+ windows.addElement( win );
+ }
+
+ public void removeWindow( JFrame win ) {
+ windows.removeElement( win );
+ }
+
public boolean floors() {
return true; // FIXME
}
import java.awt.*;
import java.awt.event.*;
-/* Quick quick quick hack */
-
public class enterPanel extends JPanel{
roomFrame rf;
roomInfo ri;
this.rf = rf;
setLayout( new BorderLayout() );
- add( "North", to = new JTextField() );
+ JPanel p = new JPanel();
+ p.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Recipient" ) );
+ p.setLayout( new BorderLayout() );
+
+ p.add( "Center", to = new JTextField() );
+
+ JButton b = new JButton( "Select" );
+ b.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ System.out.println( "User list bialog!" );
+ } } );
+
+ p.add( "East", b );
+
+ add( "North", p );
+
to.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
msg.requestFocus();
} } );
- add( "Center", msg = new JTextArea() );
+ p = new JPanel();
+ p.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Message Text" ) );
+ p.setLayout( new BorderLayout() );
- JPanel p = new JPanel();
- JButton b;
+ p.add( "Center", new JScrollPane( msg = new JTextArea(),
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ) );
+
+ msg.setLineWrap( true );
+ msg.setWrapStyleWord( true );
+
+ add( "Center", p );
+
+ p = new JPanel();
p.add( b = new JButton( "Send" ) );
b.addActionListener( new ActionListener() {
-/* expressWindow.java
- * for showing express messages...
- */
-
+import javax.swing.*;
import java.awt.*;
-
-public class expressWindow extends Frame {
- String user;
- TextArea msg;
- Button reply, ok;
-
- public expressWindow( citReply r ) {
- user = r.getArg( 3 );
-
- setTitle( user + " : express message" );
-
- setLayout( new BorderLayout() );
- NamedPanel np = new NamedPanel( "Message" );
-
- np.setLayout( new BorderLayout() );
- np.add( "Center", msg = new TextArea() );
- msg.append( r.getData() );
-
- add( "Center", np );
-
- Panel p = new Panel();
- p.add( reply = new Button( "Reply" ) );
- p.add( ok = new Button( "OK" ) );
- add( "South", p );
-
- int more = citadel.atoi( r.getArg( 0 ) );
- if( more != 0 ) new expressWindow( citadel.me.getReply( "GEXP" ) );
-
- 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 == reply ) {
- dispose();
- citadel.me.page_user( user );
- } else if( e.target == ok )
- dispose();
- return super.action( e, o );
- }
+import java.awt.event.*;
+
+public class expressWindow extends JFrame {
+ String who;
+
+ public expressWindow( citReply r ) {
+ who = r.getArg( 3 );
+ setTitle( who + " : express message" );
+
+ JPanel p = new JPanel();
+ p.setLayout( new BorderLayout() );
+ p.setBorder( BorderFactory.createTitledBorder(
+ BorderFactory.createEtchedBorder(), "Message" ) );
+
+ JTextArea t = new JTextArea( r.getData() );
+ t.setLineWrap( true );
+ t.setWrapStyleWord( true );
+
+ p.add( "Center", new JScrollPane( t ) );
+
+ Container c = getContentPane();
+ c.setLayout( new BorderLayout() );
+ c.add( "Center", p );
+
+ p = new JPanel();
+
+ JButton b;
+ p.add( b = new JButton( "Reply" ) );
+ b.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ new pageUserWindow( who );
+ closeWin();
+ } } );
+
+ p.add( b = new JButton( "Close" ) );
+ b.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ closeWin();
+ } } );
+
+ c.add( "South", p );
+
+ addWindowListener( new WindowAdapter() {
+ public void windowClosing( WindowEvent e ) {
+ closeWin();
+ }
+ } );
+
+ citadel.me.registerWindow( this );
+ pack();
+ show();
+ }
+
+ public void closeWin() {
+ citadel.me.removeWindow( this );
+ dispose();
+ System.out.println( "expressWindow:closeWin" );
+ }
}
p.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Welcome Message" ) );
p.add( "Center", message = new JTextArea() );
+ message.setLineWrap( true );
+ message.setWrapStyleWord( true );
add( "Center", p );
p = new JPanel();
p.setBorder( BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), "Goodbye Message" ) );
p.add( "Center", message = new JTextArea() );
+ message.setLineWrap( true );
+ message.setWrapStyleWord( true );
+
add( "Center", p );
p = new JPanel();
vp.add( b = new JButton( "Page User" ) );
b.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
+ new pageUserWindow();
}});
vp.add( b = new JButton( "Who Online" ) );
b.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
+ new whoOnlineWindow();
}});
vp.add( b = new JButton( "Options" ) );
public void actionPerformed( ActionEvent e ) {
}});
+ b.setEnabled( false );
+
vp.add( b = new JButton( "Server Info" ) );
b.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
}});
+ b.setEnabled( false );
+
vp.add( b = new JButton( "Logoff" ) );
b.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println( "Zap room" );
} } );
+ b.setEnabled( false );
+
jcb = new JComboBox();
jcb.addItem( "Read New" );
p.add( "North", blurb = new JTextField() );
blurb.setEditable( false );
- p.add( "Center", new JScrollPane( message = new JTextArea() ) );
+ p.add( "Center",
+ new JScrollPane( message = new JTextArea(),
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ) );
message.setEditable( false );
+ message.setLineWrap( true );
+ message.setWrapStyleWord( true );
add( "Center", p );
}
+
import javax.swing.*;
import java.io.*;
import java.net.*;
public void run() {
String server = citadel.me.server;
int port = citadel.me.port;
- boolean proxy = false;
+ boolean proxy = true;
done = false;
try {
getReply( "IDEN 0|7|" + citadel.VERSION + "|" + citadel.NAME + " " +
citadel.VERSION + " (" + getArch() + ")|" + getHostName() );
+ Thread t = new Thread() {
+ public void run() {
+ while( !citadel.me.theNet.done ) {
+ try {
+ Thread.sleep( 30000 );
+ } catch( Exception e ) {}
+
+ System.out.println( "Idle event" );
+ citadel.me.networkEvent( "NOOP" );
+ }
+ } };
+
+ t.start();
+
MsgCmd m;
while( ((m = (MsgCmd)theQueue.get()) != null) && !done ) {
citReply r = getReply( m.cmd, m.data );
if( !done )
citadel.me.lostNetwork( "Connection closed." );
+ try {
+ t.stop();
+ } catch( Exception e ) {}
}
public void done() {