ictk-cvs Mailing List for ictk - Internet Chess ToolKit (Page 3)
chess library in java, PGN, FEN, ICS
Brought to you by:
jvarsoke
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(172) |
Sep
(30) |
Oct
(4) |
Nov
|
Dec
(5) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <jva...@us...> - 2003-09-11 02:46:49
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics
In directory sc8-pr-cvs1:/tmp/cvs-serv2666/src/ictk/boardgame/chess/net/ics
Modified Files:
ICSEventRouter.java ICSProtocolHandler.java
Removed Files:
ICSErrorLog.java
Log Message:
Added connection listening to allow ICS Client to process connection termination.
Index: ICSEventRouter.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/ICSEventRouter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ICSEventRouter.java 30 Aug 2003 04:45:57 -0000 1.6
--- ICSEventRouter.java 11 Sep 2003 02:46:43 -0000 1.7
***************
*** 172,176 ****
* the following types of events for this board number:<br>
* type 1: board updates, moves forward and back, resignations<br>
! * type 2: tackback requests, draw offers, adjourn and pause requests<br>
* type 3: kibitzes, whispers, and board says<br>
* NOTE: all types must be registered independently
--- 172,176 ----
* the following types of events for this board number:<br>
* type 1: board updates, moves forward and back, resignations<br>
! * type 2: takeback requests, draw offers, adjourn and pause requests<br>
* type 3: kibitzes, whispers, and board says<br>
* NOTE: all types must be registered independently
***************
*** 207,210 ****
--- 207,220 ----
}
+ /* removeChannelListener *************************************************/
+ /** removes a listener to a particular channel.
+ *
+ * @param channelType is the EventType for this sort of channel. For
+ * example: ICSEvent.CHANNEL_EVENT is for normal
+ * channel tells, ICSEvent.SHOUT_EVENT is for
+ * shouts.
+ * @param channelNumber is number of the channel, or in the case of
+ * shouts is the type of shout.
+ */
public void removeChannelListener (int channelType,
int channelNumber,
***************
*** 222,225 ****
--- 232,241 ----
}
+ /* isChannelExclusive ****************************************************/
+ /** are channel events for this channel only routed to this channel's
+ * listener(s), or are they also send to the CHANNEL_EVENT listener.
+ * This setting has no bearing on whether the defaultListener
+ * receives the event or not.
+ */
public void setChannelExclusive (int channelType,
int channelNumber,
***************
*** 229,232 ****
--- 245,254 ----
}
+ /* isChannelExclusive ****************************************************/
+ /** are channel events for this channel only routed to this channel's
+ * listener(s), or are they also send to the CHANNEL_EVENT listener.
+ * This setting has no bearing on whether the defaultListener
+ * receives the event or not.
+ */
public boolean isChannelExclusive (int channelType,
int channelNumber) {
Index: ICSProtocolHandler.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/ICSProtocolHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ICSProtocolHandler.java 20 Aug 2003 15:42:50 -0000 1.3
--- ICSProtocolHandler.java 11 Sep 2003 02:46:43 -0000 1.4
***************
*** 28,31 ****
--- 28,33 ----
import java.net.*;
import java.io.*;
+ import ictk.boardgame.chess.net.ics.event.ICSConnectionListener;
+ import ictk.boardgame.chess.net.ics.event.ICSConnectionEvent;
/** The generic connection object. This handles logins, disconnects
***************
*** 65,68 ****
--- 67,73 ----
protected boolean isLoggedIn;
+ /** connection listeners interested in the status of the socket */
+ protected ICSConnectionListener[] conSubscribers;
+
//constructors//////////////////////////////////////////////////////////////
public ICSProtocolHandler () {
***************
*** 70,74 ****
}
-
//assessors-mutators////////////////////////////////////////////////////////
/* setHandle **************************************************************/
--- 75,78 ----
***************
*** 166,170 ****
if (socket == null)
return false;
! return socket.isConnected();
}
--- 170,174 ----
if (socket == null)
return false;
! return socket.isClosed();
}
***************
*** 202,204 ****
--- 206,244 ----
abstract public void sendCommand (String cmd, boolean echo);
+ /* addConnectionListener *************************************************/
+ public void addConnectionListener (ICSConnectionListener listener) {
+ ICSConnectionListener[] tmp = null;
+
+ if (conSubscribers == null) {
+ tmp = new ICSConnectionListener[1];
+ tmp[0] = listener;
+ }
+ else {
+ tmp = new ICSConnectionListener[conSubscribers.length+1];
+ System.arraycopy(conSubscribers, 0, tmp, 0, conSubscribers.length);
+ tmp[conSubscribers.length] = listener;
+ }
+ conSubscribers = tmp;
+ }
+
+ /* removeConnectionListener **********************************************/
+ public void removeConnectionListener (ICSConnectionListener listener) {
+ ICSConnectionListener[] tmp = null;
+
+ if (conSubscribers != null && conSubscribers.length > 1) {
+ tmp = new ICSConnectionListener[conSubscribers.length - 1];
+ int count = 0;
+ for (int i=0; i < conSubscribers.length; i++)
+ if (conSubscribers[i] != listener)
+ tmp[count++] = conSubscribers[i];
+ }
+ conSubscribers = tmp;
+ }
+
+ /* dispatchConnectionEvent ***********************************************/
+ public void dispatchConnectionEvent (ICSConnectionEvent evt) {
+ if (conSubscribers != null)
+ for (int i=0; i<conSubscribers.length; i++)
+ conSubscribers[i].connectionStatusChanged(evt);
+ }
}
--- ICSErrorLog.java DELETED ---
|
|
From: <jva...@us...> - 2003-08-30 04:46:02
|
Update of /cvsroot/ictk/ictk/samples/simpleICSClient In directory sc8-pr-cvs1:/tmp/cvs-serv9493/samples/simpleICSClient Modified Files: SimpleICSClient.java Added Files: ChannelListenerExample.java Log Message: added ChannelListenerExample to SimpleICSClient to demonstrate adding a channel listener and how to make it exclusive. --- NEW FILE: ChannelListenerExample.java --- /* * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: ChannelListenerExample.java,v 1.1 2003/08/30 04:45:57 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import ictk.boardgame.chess.net.ics.*; import ictk.boardgame.chess.net.ics.event.*; import ictk.boardgame.chess.net.ics.ui.cli.ANSIConsole; import java.util.*; /** this class demonstrates how to create a listener for particular * channels. Mostly it's used to demonstrate how a class subscribes * to a channel via the ICSEventRouter. This class will label the * messages sent to channel 1 as [help]. */ public class ChannelListenerExample implements ICSEventListener { public boolean showTimestamp = true; public static Calendar cal = new GregorianCalendar(); //colors public final static char ESC = '\u001B'; public final static String BLACK = ESC + "[0;30", YELLOW = ESC + "[0;33m", CYAN = ESC + "[0;36m", BOLD_BLACK = ESC + "[1;30m", BOLD_RED = ESC + "[1;31m", BOLD_YELLOW = ESC + "[1;33m", BOLD_CYAN = ESC + "[1;36m", PLAIN = ESC + "[0;m"; public void icsEventDispatched (ICSEvent evt) { ICSChannelEvent chEvt = (ICSChannelEvent) evt; String prefix = null; if (showTimestamp) { System.out.print(BOLD_BLACK + getTimestampAsString(evt.getTimestamp()) + PLAIN); } System.out.print("<" + evt.getEventType() + ">"); switch (chEvt.getChannel()) { case 1: System.out.print(BOLD_BLACK); System.out.print("[help]"); if (chEvt.getAccountType().is(ICSAccountType.ADMIN)) System.out.print(BOLD_YELLOW); else if (chEvt.getAccountType().is(ICSAccountType.SERVICE_REP)) System.out.print(BOLD_RED); else System.out.print(PLAIN); System.out.print(chEvt.getPlayer()); System.out.print(BOLD_BLACK); System.out.print(": "); System.out.print(CYAN); System.out.print(chEvt.getMessage()); System.out.println(PLAIN); break; default: System.out.println("subscribed to unhandled channel [" + chEvt.getChannel() + "]"); } System.out.flush(); } public String getTimestampAsString (Date date) { StringBuffer sb = new StringBuffer(5); int tmp = 0; cal.setTime(date); tmp = cal.get(Calendar.HOUR_OF_DAY); if (tmp < 10) sb.append("0"); sb.append(tmp).append(":"); tmp = cal.get(Calendar.MINUTE); if (tmp < 10) sb.append("0"); sb.append(tmp); return sb.toString(); } } Index: SimpleICSClient.java =================================================================== RCS file: /cvsroot/ictk/ictk/samples/simpleICSClient/SimpleICSClient.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SimpleICSClient.java 29 Aug 2003 08:42:21 -0000 1.3 --- SimpleICSClient.java 30 Aug 2003 04:45:57 -0000 1.4 *************** *** 35,39 **** --- 35,42 ---- import ictk.boardgame.chess.net.ics.ui.cli.ANSIConsole; + import ictk.boardgame.chess.net.ics.ICSProtocolHandler; + import ictk.boardgame.chess.net.ics.ICSEventRouter; import ictk.boardgame.chess.net.ics.fics.FICSProtocolHandler; + import ictk.boardgame.chess.net.ics.event.ICSEvent; public class SimpleICSClient { *************** *** 41,69 **** String passwd; ! FICSProtocolHandler fics; ANSIConsole ansiConsole; CommandInput commandLine; ! /** Creates new form SimpleICSClient */ ! public SimpleICSClient(String handle, String passwd) { ! this.handle = handle; ! this.passwd = passwd; ! fics = new FICSProtocolHandler(); ! ansiConsole = new ANSIConsole(); ! fics.getEventRouter().setDefaultListener(ansiConsole); ! commandLine = new CommandInput("Simple ICS Client", fics); ! } public void connect() { // Add your handling code here: ! if (!fics.isConnected()) { try { System.out.println("[Client] attempting to connect"); ! fics.setHandle(handle); ! fics.setPassword(passwd); ! fics.setLagCompensation(true); ! fics.connect(); } catch (java.net.UnknownHostException e) { --- 44,91 ---- String passwd; ! ICSProtocolHandler ics; ANSIConsole ansiConsole; CommandInput commandLine; ! /** creates a new SimpleICSClient registereing the ICS protocol handler ! * and the default listener for all events. ! */ ! public SimpleICSClient(String handle, String passwd) { ! this.handle = handle; ! this.passwd = passwd; ! ics = new FICSProtocolHandler(); ! ansiConsole = new ANSIConsole(); ! ICSEventRouter router = ics.getEventRouter(); ! router.setDefaultListener(ansiConsole); ! ! //channel 1 (help) goes to a different listener ! router.addChannelListener(ICSEvent.CHANNEL_EVENT, 1, ! new ChannelListenerExample()); ! ! //need all other channel events to still go to ansiConsole ! ics.getEventRouter().addEventListener(ICSEvent.CHANNEL_EVENT, ansiConsole); ! ! //so the main ChannelEvent listener doesn't also get the event ! router.setChannelExclusive(ICSEvent.CHANNEL_EVENT, 1, true); ! //so the defaultListener doesn't get the event ! router.setExclusive(ICSEvent.CHANNEL_EVENT, true); ! ! commandLine = new CommandInput("Simple ICS Client", ics); ! } + /** if not already connected this will establish a connection to the + * server. + */ public void connect() { // Add your handling code here: ! if (!ics.isConnected()) { try { System.out.println("[Client] attempting to connect"); ! ics.setHandle(handle); ! ics.setPassword(passwd); ! ics.setLagCompensation(true); ! ics.connect(); } catch (java.net.UnknownHostException e) { |
|
From: <jva...@us...> - 2003-08-30 04:46:01
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics
In directory sc8-pr-cvs1:/tmp/cvs-serv9493/src/ictk/boardgame/chess/net/ics
Modified Files:
ICSEventRouter.java
Log Message:
added ChannelListenerExample to SimpleICSClient to demonstrate adding a
channel listener and how to make it exclusive.
Index: ICSEventRouter.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/ICSEventRouter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ICSEventRouter.java 29 Aug 2003 08:42:21 -0000 1.5
--- ICSEventRouter.java 30 Aug 2003 04:45:57 -0000 1.6
***************
*** 33,36 ****
--- 33,38 ----
*/
public class ICSEventRouter {
+ /** key offset for integers so they can be put in the hash */
+ protected static int OFFSET = 1000;
/** the default listener receives all events or those not sent to a
** exclusive listener (depending on set options). */
***************
*** 44,60 ****
** the value is a ICSEventListener[] */
protected HashMap chSubscribers,
-
- /** subscribers to individual boards.
- ** the key is the board number.
- ** the value is a 3 element array of
- ** ICSEventListener arrays. The 3 elements
- ** indicate types of events the listener wants*/
- boardSubscribers;
-
- /** a list of which events are exclusively listed to by the
- ** subscriber (event if null) instead of also being sent
- ** to the defaultListener */
- protected boolean[] exclusive;
-
/** determines if the channel(shout, tournament channel, etc)
** events will be sent only to the listener subscribing
--- 46,49 ----
***************
*** 62,68 ****
** the CHANNEL_EVENT or SHOUT_EVENT listener will also
** receive the event. */
! protected boolean exclusiveChannel,
! exclusiveBoard;
--- 51,60 ----
** the CHANNEL_EVENT or SHOUT_EVENT listener will also
** receive the event. */
! chExclusive;
! /** a list of which events are exclusively listed to by the
! ** subscriber (event if null) instead of also being sent
! ** to the defaultListener */
! protected boolean[] exclusive;
***************
*** 70,74 ****
subscribers = new ICSEventListener[ICSEvent.NUM_EVENTS][];
chSubscribers = new HashMap();
! boardSubscribers = new HashMap();
exclusive = new boolean[ICSEvent.NUM_EVENTS];
}
--- 62,66 ----
subscribers = new ICSEventListener[ICSEvent.NUM_EVENTS][];
chSubscribers = new HashMap();
! chExclusive = new HashMap();
exclusive = new boolean[ICSEvent.NUM_EVENTS];
}
***************
*** 97,100 ****
--- 89,93 ----
*/
public void dispatch (ICSEvent evt) {
+ Integer key = null;
int type = evt.getEventType(),
i = 0;
***************
*** 108,117 ****
case ICSEvent.TOURNAMENT_CHANNEL_EVENT:
case ICSEvent.SHOUT_EVENT:
! int[] key = new int[2];
! key[0] = type;
! key[1] = ((ICSChannelEvent) evt).getChannel();
listeners = (ICSEventListener[]) chSubscribers.get(key);
! done = exclusiveChannel;
break;
--- 101,111 ----
case ICSEvent.TOURNAMENT_CHANNEL_EVENT:
case ICSEvent.SHOUT_EVENT:
! key = new Integer(type * OFFSET
! + ((ICSChannelEvent) evt).getChannel());
listeners = (ICSEventListener[]) chSubscribers.get(key);
! done = (listeners != null)
! && isChannelExclusive(type,
! ((ICSChannelEvent) evt).getChannel());
break;
***************
*** 151,156 ****
* @param icsEventNumber an ICSEvent.<FOO>_EVENT
*/
! public void addEventListener (ICSEventListener eh,
! int icsEventNumber) {
}
--- 145,153 ----
* @param icsEventNumber an ICSEvent.<FOO>_EVENT
*/
! public void addEventListener (int icsEventNumber,
! ICSEventListener eh) {
!
! subscribers[icsEventNumber]
! = _addListener(subscribers[icsEventNumber], eh);
}
***************
*** 197,208 ****
* shouts is the type of shout.
*/
! public void addChannelListener (ICSEventListener eh,
! int channelType,
! int channelNumber) {
! int[] key = new int[2];
! ICSEventListener[] list;
! key[0] = channelType;
! key[1] = channelNumber;
list = (ICSEventListener[]) chSubscribers.get(key);
--- 194,203 ----
* shouts is the type of shout.
*/
! public void addChannelListener (int channelType,
! int channelNumber,
! ICSEventListener eh) {
! Integer key = new Integer(channelType * OFFSET + channelNumber);
! ICSEventListener[] list;
list = (ICSEventListener[]) chSubscribers.get(key);
***************
*** 212,224 ****
}
! public void removeChannelListener (ICSEventListener eh,
! int channelType,
! int channelNumber) {
! int[] key = new int[2];
ICSEventListener[] list;
- key[0] = channelType;
- key[1] = channelNumber;
-
list = (ICSEventListener[]) chSubscribers.get(key);
list = _removeListener(list, eh);
--- 207,216 ----
}
! public void removeChannelListener (int channelType,
! int channelNumber,
! ICSEventListener eh) {
! Integer key = new Integer(channelType * OFFSET + channelNumber);
ICSEventListener[] list;
list = (ICSEventListener[]) chSubscribers.get(key);
list = _removeListener(list, eh);
***************
*** 228,231 ****
--- 220,238 ----
else
chSubscribers.put(key, list);
+ }
+
+ public void setChannelExclusive (int channelType,
+ int channelNumber,
+ boolean t) {
+ Integer key = new Integer(channelType * OFFSET + channelNumber);
+ chExclusive.put(key, ((t) ? Boolean.TRUE : Boolean.FALSE));
+ }
+
+ public boolean isChannelExclusive (int channelType,
+ int channelNumber) {
+ Integer key = new Integer(channelType * OFFSET + channelNumber);
+ Boolean b = null;
+ return ((b = (Boolean) chExclusive.get(key)) != null)
+ && b == Boolean.TRUE;
}
|
|
From: <jva...@us...> - 2003-08-29 08:42:26
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics
In directory sc8-pr-cvs1:/tmp/cvs-serv27976/src/ictk/boardgame/chess/net/ics/fics
Modified Files:
FICSProtocolHandler.java
Log Message:
Seperated out the GUI from SimpleICSClient so it is more apparent how things
are set up. Added CommandInput. Client GUI is now AWT -- better response to
typing. Also improving the Router
Index: FICSProtocolHandler.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics/FICSProtocolHandler.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** FICSProtocolHandler.java 25 Aug 2003 01:29:00 -0000 1.17
--- FICSProtocolHandler.java 29 Aug 2003 08:42:21 -0000 1.18
***************
*** 223,230 ****
}
- public ICSEventRouter getRouter() {
- return router;
- }
-
//methods/////////////////////////////////////////////////////////////////
public void connect ()
--- 223,226 ----
|
|
From: <jva...@us...> - 2003-08-29 08:42:26
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event
In directory sc8-pr-cvs1:/tmp/cvs-serv27976/src/ictk/boardgame/chess/net/ics/event
Modified Files:
ICSEvent.java
Log Message:
Seperated out the GUI from SimpleICSClient so it is more apparent how things
are set up. Added CommandInput. Client GUI is now AWT -- better response to
typing. Also improving the Router
Index: ICSEvent.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/ICSEvent.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** ICSEvent.java 20 Aug 2003 15:42:50 -0000 1.8
--- ICSEvent.java 29 Aug 2003 08:42:21 -0000 1.9
***************
*** 46,81 ****
public static final int
UNKNOWN_EVENT = 0,
BOARD_UPDATE_EVENT = 1,
! CHANNEL_EVENT = 2,
! SHOUT_EVENT = 3,
- SEEK_AD_EVENT = 4,
- SEEK_REMOVE_EVENT = 5,
! TELL_EVENT = 6,
! SAY_EVENT = 7,
! KIBITZ_EVENT = 8,
! WHISPER_EVENT = 9,
! QTELL_EVENT = 14,
! AUTO_SALUTE_EVENT = 15,
! MOVE_LIST_EVENT = 16,
! GAME_RESULT_EVENT = 17,
! MATCH_REQUEST_EVENT = 18,
! TAKEBACK_REQUEST_EVENT = 19,
! PLAYER_NOTIFICATION_EVENT = 20,
! GAME_NOTIFICATION_EVENT = 21,
! AVAIL_INFO_EVENT = 22,
! USER_DEFINED_EVENT = 23,
! SEEK_AD_READABLE_EVENT = 24,
! SEEK_REMOVE_READABLE_EVENT = 25,
! BOARD_SAY_EVENT = 26,
! SEEK_CLEAR_EVENT = 27,
! PLAYER_CONNECTION_EVENT = 28,
! GAME_CREATED_EVENT = 29,
! HISTORY_EVENT = 30,
! TOURNAMENT_CHANNEL_EVENT = 31,
! NUM_EVENTS = 32;
/** each event has a type for easy casting */
--- 46,85 ----
public static final int
UNKNOWN_EVENT = 0,
+
BOARD_UPDATE_EVENT = 1,
! GAME_CREATED_EVENT = 2,
! GAME_RESULT_EVENT = 3,
! GAME_NOTIFICATION_EVENT = 4,
! TAKEBACK_REQUEST_EVENT = 5,
! CHANNEL_EVENT = 6,
! SHOUT_EVENT = 7,
! TOURNAMENT_CHANNEL_EVENT = 8,
! TELL_EVENT = 9,
! SAY_EVENT = 10,
! SEEK_AD_EVENT = 11,
! SEEK_REMOVE_EVENT = 12,
! SEEK_AD_READABLE_EVENT = 13,
! SEEK_REMOVE_READABLE_EVENT = 14,
! SEEK_CLEAR_EVENT = 15,
!
! KIBITZ_EVENT = 16,
! WHISPER_EVENT = 17,
! BOARD_SAY_EVENT = 18,
!
! QTELL_EVENT = 19,
! AUTO_SALUTE_EVENT = 20,
! MOVE_LIST_EVENT = 21,
! MATCH_REQUEST_EVENT = 22,
! PLAYER_NOTIFICATION_EVENT = 23,
! AVAIL_INFO_EVENT = 24,
! USER_DEFINED_EVENT = 25,
!
! PLAYER_CONNECTION_EVENT = 26,
! HISTORY_EVENT = 27,
! NUM_EVENTS = 28;
/** each event has a type for easy casting */
|
|
From: <jva...@us...> - 2003-08-29 08:42:26
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics
In directory sc8-pr-cvs1:/tmp/cvs-serv27976/src/ictk/boardgame/chess/net/ics
Modified Files:
ICSEventRouter.java
Log Message:
Seperated out the GUI from SimpleICSClient so it is more apparent how things
are set up. Added CommandInput. Client GUI is now AWT -- better response to
typing. Also improving the Router
Index: ICSEventRouter.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/ICSEventRouter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ICSEventRouter.java 20 Aug 2003 15:42:50 -0000 1.4
--- ICSEventRouter.java 29 Aug 2003 08:42:21 -0000 1.5
***************
*** 33,45 ****
*/
public class ICSEventRouter {
! /** the default router receives all events that aren't sent elsewhere*/
! ICSEventListener defaultRoute;
/** subscribers to ICSEvents */
protected ICSEventListener[][] subscribers;
/** subscribers to individual channels.
! ** the key is the channel number,
** the value is a ICSEventListener[] */
protected HashMap chSubscribers,
/** subscribers to individual boards.
** the key is the board number.
--- 33,48 ----
*/
public class ICSEventRouter {
! /** the default listener receives all events or those not sent to a
! ** exclusive listener (depending on set options). */
! ICSEventListener defaultListener;
/** subscribers to ICSEvents */
protected ICSEventListener[][] subscribers;
/** subscribers to individual channels.
! ** the key is an int[2] with [0] set to the ChannelType (shout, TCh etc)
! ** and the [1] set the the channel number,
** the value is a ICSEventListener[] */
protected HashMap chSubscribers,
+
/** subscribers to individual boards.
** the key is the board number.
***************
*** 49,74 ****
boardSubscribers;
public ICSEventRouter () {
subscribers = new ICSEventListener[ICSEvent.NUM_EVENTS][];
chSubscribers = new HashMap();
boardSubscribers = new HashMap();
}
! /* setDefaltRoute ********************************************************/
/** This listener receives all message that are not exclusively
* processed by some other listener. Uncategorized output is also
! * sent to the default route.
*/
! public void setDefaultRoute (ICSEventListener eh) {
! defaultRoute = eh;
}
! /* getDefaltRoute ********************************************************/
/** This listener receives all message that are not exclusively
* processed by some other listener. Uncategorized output is also
! * sent to the default route.
*/
! public ICSEventListener getDefaultRoute () {
! return defaultRoute;
}
--- 52,93 ----
boardSubscribers;
+ /** a list of which events are exclusively listed to by the
+ ** subscriber (event if null) instead of also being sent
+ ** to the defaultListener */
+ protected boolean[] exclusive;
+
+ /** determines if the channel(shout, tournament channel, etc)
+ ** events will be sent only to the listener subscribing
+ ** specifically to the channel number. If this is false
+ ** the CHANNEL_EVENT or SHOUT_EVENT listener will also
+ ** receive the event. */
+ protected boolean exclusiveChannel,
+
+ exclusiveBoard;
+
+
public ICSEventRouter () {
subscribers = new ICSEventListener[ICSEvent.NUM_EVENTS][];
chSubscribers = new HashMap();
boardSubscribers = new HashMap();
+ exclusive = new boolean[ICSEvent.NUM_EVENTS];
}
! /* setDefaltListener *****************************************************/
/** This listener receives all message that are not exclusively
* processed by some other listener. Uncategorized output is also
! * sent to the default listener.
*/
! public void setDefaultListener (ICSEventListener eh) {
! defaultListener = eh;
}
! /* getDefaltListener *****************************************************/
/** This listener receives all message that are not exclusively
* processed by some other listener. Uncategorized output is also
! * sent to the default listener.
*/
! public ICSEventListener getDefaultListener () {
! return defaultListener;
}
***************
*** 78,86 ****
*/
public void dispatch (ICSEvent evt) {
! if (subscribers[evt.getEventType()] != null) {
}
! else {
! defaultRoute.icsEventDispatched(evt);
}
}
--- 97,146 ----
*/
public void dispatch (ICSEvent evt) {
! int type = evt.getEventType(),
! i = 0;
! ICSEventListener[] listeners = null;
! boolean done = false,
! done2 = false;
!
! switch (type) {
! //channel events
! case ICSEvent.CHANNEL_EVENT:
! case ICSEvent.TOURNAMENT_CHANNEL_EVENT:
! case ICSEvent.SHOUT_EVENT:
! int[] key = new int[2];
! key[0] = type;
! key[1] = ((ICSChannelEvent) evt).getChannel();
!
! listeners = (ICSEventListener[]) chSubscribers.get(key);
! done = exclusiveChannel;
!
! break;
!
! //board events
! case ICSEvent.BOARD_UPDATE_EVENT:
! case ICSEvent.KIBITZ_EVENT:
! case ICSEvent.WHISPER_EVENT:
! case ICSEvent.BOARD_SAY_EVENT:
!
! default:
! break;
}
!
! //send to the specific listerners from the switch
! if (listeners != null)
! for (i = 0; i < listeners.length; i++)
! listeners[i].icsEventDispatched(evt);
!
! //send to the event subscribers if the switch listener wasn't exclusive
! if (!done
! && (listeners = subscribers[type]) != null) {
! for (i=0; i < listeners.length; i++)
! listeners[i].icsEventDispatched(evt);
! done2 = true;
}
+
+ //send to the default route if this event isn't exclusive
+ if (!exclusive[type] && defaultListener != null)
+ defaultListener.icsEventDispatched(evt);
}
***************
*** 95,103 ****
}
/* addBoardListener ******************************************************/
/** adding this type of listener will subscribe the listener to
* the following types of events for this board number:<br>
! * type 1: board updates and moves, resignations<br>
! * type 2: tackbacks, draw offers, adjourn and pause requests<br>
* type 3: kibitzes, whispers, and board says<br>
* NOTE: all types must be registered independently
--- 155,179 ----
}
+ /* setExclusive **********************************************************/
+ /** should the event be routed only to listeners subscribed to this
+ * event, or also to the default listener.
+ *
+ * @param t if true then the default listener will not receive the
+ * event even if there are no listeners for this event.
+ */
+ public void setExclusive (int eventType, boolean t) {
+ exclusive[eventType] = t;
+ }
+
+ /* isExclusive ***********************************************************/
+ public boolean isExclusive (int eventType) {
+ return exclusive[eventType];
+ }
+
/* addBoardListener ******************************************************/
/** adding this type of listener will subscribe the listener to
* the following types of events for this board number:<br>
! * type 1: board updates, moves forward and back, resignations<br>
! * type 2: tackback requests, draw offers, adjourn and pause requests<br>
* type 3: kibitzes, whispers, and board says<br>
* NOTE: all types must be registered independently
***************
*** 111,118 ****
/** adds a listener to a particular channel. This is useful if you want
* to log particular channels, or send them to different display
! * areas.
*/
public void addChannelListener (ICSEventListener eh,
int channelNumber) {
}
}
--- 187,263 ----
/** adds a listener to a particular channel. This is useful if you want
* to log particular channels, or send them to different display
! * areas. If a listener wish to listen to all channel events then
! * it would be better to subscribe via addEventListener().
! *
! * @param channelType is the EventType for this sort of channel. For
! * example: ICSEvent.CHANNEL_EVENT is for normal
! * channel tells, ICSEvent.SHOUT_EVENT is for
! * shouts.
! * @param channelNumber is number of the channel, or in the case of
! * shouts is the type of shout.
*/
public void addChannelListener (ICSEventListener eh,
+ int channelType,
int channelNumber) {
+ int[] key = new int[2];
+ ICSEventListener[] list;
+
+ key[0] = channelType;
+ key[1] = channelNumber;
+
+ list = (ICSEventListener[]) chSubscribers.get(key);
+ list = _addListener(list, eh);
+
+ chSubscribers.put(key, list);
}
+
+ public void removeChannelListener (ICSEventListener eh,
+ int channelType,
+ int channelNumber) {
+ int[] key = new int[2];
+ ICSEventListener[] list;
+
+ key[0] = channelType;
+ key[1] = channelNumber;
+
+ list = (ICSEventListener[]) chSubscribers.get(key);
+ list = _removeListener(list, eh);
+
+ if (list == null)
+ chSubscribers.remove(key);
+ else
+ chSubscribers.put(key, list);
+ }
+
+ /* _addListener **********************************************************/
+ protected ICSEventListener[] _addListener (ICSEventListener[] list,
+ ICSEventListener evt) {
+ ICSEventListener[] tmp = null;
+
+ if (list == null) {
+ tmp = new ICSEventListener[1];
+ tmp[0] = evt;
+ }
+ else {
+ tmp = new ICSEventListener[list.length+1];
+ System.arraycopy(list, 0, tmp, 0, list.length);
+ tmp[list.length] = evt;
+ }
+ return tmp;
+ }
+
+ /* _removeListener *******************************************************/
+ protected ICSEventListener[] _removeListener (ICSEventListener[] list,
+ ICSEventListener evt) {
+ ICSEventListener[] tmp = null;
+ if (list != null && list.length > 1) {
+ tmp = new ICSEventListener[list.length - 1];
+ int count = 0;
+ for (int i=0; i < list.length; i++)
+ if (list[i] != evt)
+ tmp[count++] = list[i];
+ }
+ return tmp;
+ }
+
}
|
|
From: <jva...@us...> - 2003-08-29 08:42:25
|
Update of /cvsroot/ictk/ictk/samples/simpleICSClient In directory sc8-pr-cvs1:/tmp/cvs-serv27976/samples/simpleICSClient Modified Files: SimpleICSClient.java Added Files: CommandInput.java Removed Files: SimpleICSClient.form Log Message: Seperated out the GUI from SimpleICSClient so it is more apparent how things are set up. Added CommandInput. Client GUI is now AWT -- better response to typing. Also improving the Router --- NEW FILE: CommandInput.java --- /* * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: CommandInput.java,v 1.1 2003/08/29 08:42:21 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* CommandInput ***********************************************************/ /** * This is a no frills Command input window. * @author jvarsoke */ import java.awt.*; import java.awt.event.*; import ictk.boardgame.chess.net.ics.ICSProtocolHandler; public class CommandInput extends Frame implements ActionListener { TextField tfCommand; ICSProtocolHandler ics; /** Creates new form JCommandInput */ public CommandInput(String title, ICSProtocolHandler ics) { super(title); this.ics = ics; initComponents(); } /** This method is called from within the constructor to * initialize the form. */ private void initComponents() { tfCommand = new TextField(); tfCommand.addActionListener(this); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { ics.disconnect(); System.exit(0); } }); tfCommand.setFont(new Font("Lucida Sans Typewriter", 0, 12)); tfCommand.addActionListener(this); add(tfCommand, BorderLayout.CENTER); pack(); java.awt.Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setSize(new java.awt.Dimension(500, 18)); //setLocation((screenSize.width-500)/2,(screenSize.height-18)/2); setLocation(27,(screenSize.height-60)); } public void actionPerformed (ActionEvent evt) { ics.sendCommand(tfCommand.getText()); tfCommand.setText(""); } } Index: SimpleICSClient.java =================================================================== RCS file: /cvsroot/ictk/ictk/samples/simpleICSClient/SimpleICSClient.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimpleICSClient.java 20 Aug 2003 14:10:17 -0000 1.2 --- SimpleICSClient.java 29 Aug 2003 08:42:21 -0000 1.3 *************** *** 24,33 **** */ - /* - * SimpleICSClient.java - * - * Created on March 12, 2002, 10:43 PM - */ - /* SimpleICSClient ***********************************************************/ /** --- 24,27 ---- *************** *** 39,107 **** * @author jvarsoke */ - public class SimpleICSClient extends javax.swing.JFrame implements java.awt.event.ActionListener { ! static java.lang.String handle; ! static java.lang.String passwd; ! ictk.boardgame.chess.net.ics.fics.FICSProtocolHandler fics; ! ictk.boardgame.chess.net.ics.ui.cli.ANSIConsole ansiConsole; /** Creates new form SimpleICSClient */ ! public SimpleICSClient() { ! initComponents(); ! fics = new ictk.boardgame.chess.net.ics.fics.FICSProtocolHandler(); ! ansiConsole = new ictk.boardgame.chess.net.ics.ui.cli.ANSIConsole(); ! fics.getRouter().setDefaultRoute(ansiConsole); ! connect(null); } ! /** This method is called from within the constructor to ! * initialize the form. ! * WARNING: Do NOT modify this code. The content of this method is ! * always regenerated by the Form Editor. ! */ ! private void initComponents() {//GEN-BEGIN:initComponents ! tfCommand = new javax.swing.JTextField(); ! bConnect = new javax.swing.JButton(); ! ! setTitle("ICTK Sample ICS Client"); ! addWindowListener(new java.awt.event.WindowAdapter() { ! public void windowClosing(java.awt.event.WindowEvent evt) { ! exitForm(evt); ! } ! }); ! ! tfCommand.setFont(new java.awt.Font("Lucida Sans Typewriter", 0, 12)); ! tfCommand.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! commandPerformed(evt); ! } ! }); ! ! getContentPane().add(tfCommand, java.awt.BorderLayout.CENTER); ! ! bConnect.setText("Connect"); ! bConnect.addActionListener(new java.awt.event.ActionListener() { ! public void actionPerformed(java.awt.event.ActionEvent evt) { ! connect(evt); ! } ! }); ! ! getContentPane().add(bConnect, java.awt.BorderLayout.EAST); ! ! pack(); ! java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); ! setSize(new java.awt.Dimension(500, 18)); ! //setLocation((screenSize.width-500)/2,(screenSize.height-18)/2); ! setLocation(27,(screenSize.height-60)); ! }//GEN-END:initComponents ! ! private void connect(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connect // Add your handling code here: ! if (!fics.isConnected()) try { ! System.out.println("Client: attempting to connect"); fics.setHandle(handle); fics.setPassword(passwd); --- 33,65 ---- * @author jvarsoke */ ! import ictk.boardgame.chess.net.ics.ui.cli.ANSIConsole; ! import ictk.boardgame.chess.net.ics.fics.FICSProtocolHandler; ! public class SimpleICSClient { ! String handle; ! String passwd; ! ! FICSProtocolHandler fics; ! ANSIConsole ansiConsole; ! CommandInput commandLine; /** Creates new form SimpleICSClient */ ! public SimpleICSClient(String handle, String passwd) { ! this.handle = handle; ! this.passwd = passwd; ! fics = new FICSProtocolHandler(); ! ansiConsole = new ANSIConsole(); ! fics.getEventRouter().setDefaultListener(ansiConsole); ! commandLine = new CommandInput("Simple ICS Client", fics); } ! public void connect() { // Add your handling code here: ! if (!fics.isConnected()) { try { ! System.out.println("[Client] attempting to connect"); fics.setHandle(handle); fics.setPassword(passwd); *************** *** 115,137 **** e.printStackTrace(); } ! else ! fics.disconnect(); ! }//GEN-LAST:event_connect ! ! private void conntection(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_conntection ! // Add your handling code here: ! ! }//GEN-LAST:event_conntection ! ! private void commandPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_commandPerformed ! // Add your handling code here: ! fics.sendCommand(tfCommand.getText()); ! tfCommand.setText(""); ! }//GEN-LAST:event_commandPerformed ! /** Exit the Application */ ! private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm ! System.exit(0); ! }//GEN-LAST:event_exitForm /** --- 73,82 ---- e.printStackTrace(); } ! } ! } ! public void setVisible (boolean t) { ! commandLine.setVisible(t); ! } /** *************** *** 139,158 **** */ public static void main(String args[]) { if (args.length < 2) { ! System.err.println("must supply username and password"); System.exit(1); } ! handle = args[0]; ! passwd = args[1]; ! new SimpleICSClient().show(); } - - public void actionPerformed(java.awt.event.ActionEvent actionEvent) { - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextField tfCommand; - private javax.swing.JButton bConnect; - // End of variables declaration//GEN-END:variables - } --- 84,95 ---- */ public static void main(String args[]) { + SimpleICSClient client = null; if (args.length < 2) { ! System.err.println("You must supply username and password"); System.exit(1); } ! client = new SimpleICSClient(args[0], args[1]); ! client.setVisible(true); ! client.connect(); } } --- SimpleICSClient.form DELETED --- |
|
From: <jva...@us...> - 2003-08-29 04:43:31
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event
In directory sc8-pr-cvs1:/tmp/cvs-serv29501
Modified Files:
playerConnection.xml
Log Message:
Added for Notify when you are on user's notify list, but they are not
on yours.
Index: playerConnection.xml
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/playerConnection.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** playerConnection.xml 20 Aug 2003 22:28:06 -0000 1.1
--- playerConnection.xml 29 Aug 2003 04:43:27 -0000 1.2
***************
*** 50,53 ****
--- 50,58 ----
functname="Notification"
/>
+ <member id="pcon:onNotifyList" typeref="boolean"
+ varname="onNotifyList"
+ functname="OnNotifyList"
+ />
+
<!--pin parser-->
***************
*** 104,107 ****
--- 109,113 ----
\shas\s
(arrived|departed)
+ (\sand\sisn't\son\syour\snotify\slist)?
\.
</regex>
***************
*** 113,116 ****
--- 119,123 ----
evt.setConnected("arrived".equals(m.group(4)));
evt.setNotification(true);
+ evt.setOnNotifyList(m.group(5) != null);
evt.setEventType(ICSEvent.PLAYER_NOTIFICATION_EVENT);
</assignMatches>
***************
*** 125,131 ****
if (evt.isConnected())
! sb.append("arrived.");
else
! sb.append("departed.");
</code>
</toNative>
--- 132,143 ----
if (evt.isConnected())
! sb.append("arrived");
else
! sb.append("departed");
!
! if (evt.isOnNotifyList())
! sb.append(" and isn't on your notify list");
!
! sb.append(".");
</code>
</toNative>
|
|
From: <jva...@us...> - 2003-08-29 04:43:05
|
Update of /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event/data In directory sc8-pr-cvs1:/tmp/cvs-serv29346 Modified Files: FICSPlayerNotificationParserTest.data Log Message: Added for Notify when you are on user's notify list, but they are not on yours. Index: FICSPlayerNotificationParserTest.data =================================================================== RCS file: /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event/data/FICSPlayerNotificationParserTest.data,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FICSPlayerNotificationParserTest.data 24 Aug 2003 01:48:45 -0000 1.1 --- FICSPlayerNotificationParserTest.data 29 Aug 2003 04:43:02 -0000 1.2 *************** *** 5,6 **** --- 5,10 ---- ## :Notification: mrbishop has departed. + ## + Notification: drakorg has arrived and isn't on your notify list. + ## + Notification: drakorg has departed and isn't on your notify list. |
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event In directory sc8-pr-cvs1:/tmp/cvs-serv17762 Removed Files: ICSSeekAdReadableEvent.java ICSSeekClearEvent.java ICSSeekEvent.java ICSSeekRemoveEvent.java Log Message: Removing more files --- ICSSeekAdReadableEvent.java DELETED --- --- ICSSeekClearEvent.java DELETED --- --- ICSSeekEvent.java DELETED --- --- ICSSeekRemoveEvent.java DELETED --- |
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics/event In directory sc8-pr-cvs1:/tmp/cvs-serv16505 Removed Files: FICSSeekAdReadableEventParser.java FICSSeekClearEventParser.java FICSSeekRemoveEventParser.java Log Message: removing more files that were hanging around --- FICSSeekAdReadableEventParser.java DELETED --- --- FICSSeekClearEventParser.java DELETED --- --- FICSSeekRemoveEventParser.java DELETED --- |
Update of /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event
In directory sc8-pr-cvs1:/tmp/cvs-serv16108
Modified Files:
AllTests.java
Removed Files:
FICSSeekAdReadableEventParserTest.java
FICSSeekRemoveEventParserTest.java
Log Message:
Removing a few lingering files.
Index: AllTests.java
===================================================================
RCS file: /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event/AllTests.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** AllTests.java 26 Aug 2003 20:16:01 -0000 1.4
--- AllTests.java 27 Aug 2003 16:24:35 -0000 1.5
***************
*** 50,53 ****
--- 50,55 ----
suite.addTest(new TestSuite(FICSShoutParserTest.class));
suite.addTest(new TestSuite(FICSTellParserTest.class));
+ suite.addTest(new TestSuite(FICSMoveListParserTest.class));
+ suite.addTest(new TestSuite(FICSBoardUpdateStyle12ParserTest.class));
return suite;
--- FICSSeekAdReadableEventParserTest.java DELETED ---
--- FICSSeekRemoveEventParserTest.java DELETED ---
|
|
From: <jva...@us...> - 2003-08-26 20:43:15
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics/event
In directory sc8-pr-cvs1:/tmp/cvs-serv30299/src/ictk/boardgame/chess/net/ics/fics/event
Modified Files:
FICSMoveListParser.java
Log Message:
parser test generation added to build.xml. Extra \n eliminated in MoveListParser.toNative()
Index: FICSMoveListParser.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics/event/FICSMoveListParser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FICSMoveListParser.java 24 Aug 2003 07:16:36 -0000 1.2
--- FICSMoveListParser.java 26 Aug 2003 20:43:09 -0000 1.3
***************
*** 406,412 ****
.append(")\n");
}
-
- if (!moves[moves.length-1].isBlack())
- sb.append("\n");
}
--- 406,409 ----
|
|
From: <jva...@us...> - 2003-08-26 20:43:15
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event In directory sc8-pr-cvs1:/tmp/cvs-serv30299/src/ictk/boardgame/chess/net/ics/event Modified Files: ICSSeekClearEvent.java ICSSeekRemoveEvent.java Log Message: parser test generation added to build.xml. Extra \n eliminated in MoveListParser.toNative() Index: ICSSeekClearEvent.java =================================================================== RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/ICSSeekClearEvent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ICSSeekClearEvent.java 25 Aug 2003 01:29:00 -0000 1.4 --- ICSSeekClearEvent.java 26 Aug 2003 20:43:09 -0000 1.5 *************** *** 27,31 **** * This file was auto-generated * by $Id$ ! * on Sun Aug 24 18:48:29 EST 2003 *--------------------------------------------------------------------------*/ --- 27,31 ---- * This file was auto-generated * by $Id$ ! * on Tue Aug 26 15:36:23 EST 2003 *--------------------------------------------------------------------------*/ Index: ICSSeekRemoveEvent.java =================================================================== RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/ICSSeekRemoveEvent.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ICSSeekRemoveEvent.java 25 Aug 2003 01:29:00 -0000 1.3 --- ICSSeekRemoveEvent.java 26 Aug 2003 20:43:09 -0000 1.4 *************** *** 27,31 **** * This file was auto-generated * by $Id$ ! * on Sun Aug 24 20:18:58 EST 2003 *--------------------------------------------------------------------------*/ --- 27,31 ---- * This file was auto-generated * by $Id$ ! * on Tue Aug 26 15:36:23 EST 2003 *--------------------------------------------------------------------------*/ |
|
From: <jva...@us...> - 2003-08-26 20:43:14
|
Update of /cvsroot/ictk/ictk
In directory sc8-pr-cvs1:/tmp/cvs-serv30299
Modified Files:
build.xml
Log Message:
parser test generation added to build.xml. Extra \n eliminated in MoveListParser.toNative()
Index: build.xml
===================================================================
RCS file: /cvsroot/ictk/ictk/build.xml,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** build.xml 23 Aug 2003 05:52:06 -0000 1.24
--- build.xml 26 Aug 2003 20:43:08 -0000 1.25
***************
*** 68,71 ****
--- 68,73 ----
<property name="xslt.ics.event.dir"
value="${source.dir}/ictk/boardgame/chess/net/ics/event"/>
+ <property name="xslt.ics.event.parser.dir"
+ value="${test.dir}/ictk/boardgame/chess/net/ics/fics/event"/>
<!-- compile path for XSLT -->
***************
*** 147,150 ****
--- 149,153 ----
if="xalan_is_good"
description="generates source code from XML files">
+ <!-- event and parsers -->
<xslt
basedir="${xslt.ics.event.dir}"
***************
*** 163,167 ****
--- 166,186 ----
includes="*.tmp.log"
/>
+ </concat>
+ <!-- parser tests -->
+ <xslt
+ basedir="${xslt.ics.event.parser.dir}"
+ destdir="${xslt.ics.event.parser.dir}"
+ classpathref="xslt.class.path"
+ style="${xslt.ics.event.parser.dir}/templateParser.xsl"
+ includes="parserTests.xml"
+ extension=".tmp.log"
+ force="yes"
+ >
+ </xslt>
+ <concat destfile="${xslt.ics.event.parser.dir}/genfiles.log">
+ <fileset dir="${xslt.ics.event.parser.dir}"
+ includes="*.tmp.log"
+ />
</concat>
<!-- get rid of the useless log files -->
***************
*** 170,174 ****
--- 189,198 ----
includes="*.tmp.log"
/>
+ <fileset dir="${xslt.ics.event.parser.dir}"
+ includes="*.tmp.log"
+ />
</delete>
+
+ <!-- report all files -->
<echo>Generated Files</echo>
<concat>
***************
*** 176,180 ****
--- 200,208 ----
includes="genfiles.log"
/>
+ <fileset dir="${xslt.ics.event.parser.dir}"
+ includes="genfiles.log"
+ />
</concat>
+
</target>
|
Update of /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event In directory sc8-pr-cvs1:/tmp/cvs-serv24797/test/ictk/boardgame/chess/net/ics/fics/event Modified Files: AllTests.java Added Files: parserTests.xml templateParser.xsl unitTest.dtd Removed Files: FICSBoardUpdateStyle12ParserTest.java FICSChannelParserTest.java FICSGameCreatedParserTest.java FICSGameNotificationParserTest.java FICSKibitzParserTest.java FICSMoveListParserTest.java FICSPlayerConnectionParserTest.java FICSPlayerNotificationParserTest.java FICSSeekAdParserTest.java FICSSeekAdReadableParserTest.java FICSSeekClearParserTest.java FICSSeekRemoveParserTest.java FICSShoutParserTest.java FICSTellParserTest.java makeTest.pl testTemplate.txt Log Message: replaced all fics/event/Tests with xslt generated test files. --- NEW FILE: parserTests.xml --- <?xml version="1.0" encoding="utf-8" standalone="no"?> <!-- * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: parserTests.xml,v 1.1 2003/08/26 20:16:01 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!DOCTYPE ictkml SYSTEM "unitTest.dtd" [ ]> <unitTest> <!-- kibitz ............................................................--> <unit id="kibitz" class="Kibitz" event="Kibitz" > <test name="Message0" iochunk="0" > <code format="java"> assertTrue(evt.getPlayer().equals("Handle")); assertFalse(evt.getAccountType().is(ICSAccountType.UNREGISTERED)); assertTrue(evt.getRating().get() == 1902); assertTrue(evt.getBoardNumber() == 7); assertTrue(evt.getMessage().equals("hey")); </code> </test> </unit> <!-- channel ...........................................................--> <unit id="channel" class="Channel" event="Channel" > <test name="Message0" iochunk="0" > <code format="java"> assertTrue("Gorgonian".equals(evt.getPlayer())); assertTrue(evt.getChannel() == 50); assertTrue("da".equals(evt.getMessage())); </code> </test> <test name="Message1" iochunk="1" > <code format="java"> assertTrue(evt.getAccountType().is(ICSAccountType.CHESS_ADVISOR)); </code> </test> <test name="Message3" iochunk="3" > <code format="java"> assertTrue(evt.getAccountType().is(ICSAccountType.ADMIN)); assertTrue(evt.getAccountType().is(ICSAccountType.SERVICE_REP)); assertTrue(evt.getAccountType().is(ICSAccountType.CHESS_ADVISOR)); assertTrue(evt.getAccountType().is(ICSAccountType.TOURNAMENT_MANAGER)); assertTrue(evt.getChannel() == 49); </code> </test> </unit> <!-- shout .............................................................--> <unit id="shout" class="Shout" event="Channel" > </unit> <!-- tell ..............................................................--> <unit id="tell" class="Tell" event="Tell" > <test name="Message0" iochunk="0" > <code format="java"> assertTrue(evt.getPlayer().equals("Handle")); assertTrue(evt.getMessage().equals("Hey")); assertFalse(evt.isFake()); assertTrue(evt.getEventType() == ICSEvent.TELL_EVENT); assertFalse(evt.getMessage().equals("hey")); </code> </test> <test name="Message1" iochunk="1" > <code format="java"> assertTrue(evt.getPlayer().equals("Handle")); assertTrue(evt.getAccountType().is(ICSAccountType.COMPUTER)); assertTrue(evt.getMessage().equals("Hey")); assertFalse(evt.isFake()); assertTrue(evt.getEventType() == ICSEvent.TELL_EVENT); assertFalse(evt.getMessage().equals("hey")); </code> </test> </unit> <!-- player connection..................................................--> <unit id="pin" class="PlayerConnection" event="PlayerConnection" > </unit> <!-- player notification................................................--> <unit id="pnot" class="PlayerNotification" event="PlayerConnection" > </unit> <!-- game created ......................................................--> <unit id="gin" class="GameCreated" event="GameCreated" > </unit> <!-- game notification..................................................--> <unit id="gnot" class="GameNotification" event="GameNotification" > </unit> <!-- game result .......................................................--> <unit id="game_result" class="GameResult" event="GameResult" > </unit> <!-- seek ad ...........................................................--> <unit id="seekad" class="SeekAd" event="SeekAd" > </unit> <!-- seek ad readable ..................................................--> <unit id="seekadreadable" class="SeekAdReadable" event="SeekAd" > </unit> <!-- seek clear ........................................................--> <unit id="seek_clear" class="SeekClear" event="SeekClear" > </unit> <!-- seek remove .......................................................--> <unit id="seek_remove" class="SeekRemove" event="SeekRemove" > </unit> <!-- board update style 12 .............................................--> <unit id="style12" class="BoardUpdateStyle12" event="BoardUpdate" > </unit> <!-- move list .........................................................--> <unit id="movelist" class="MoveList" event="MoveList" > </unit> <!-- <unit id="tell" class="Tell" event="Tell" > <test name="Message0" iochunk="0" > <code format="java"> </code> </test> </unit> --> </unitTest> --- NEW FILE: templateParser.xsl --- <?xml version="1.0"?> <!-- * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: templateParser.xsl,v 1.1 2003/08/26 20:16:01 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:redirect="http://xml.apache.org/xalan/redirect" xmlns:java="java" extension-element-prefixes="redirect" > <xsl:output method="text" omit-xml-declaration="yes"/> <xsl:template match="unitTest"> <xsl:apply-templates select="unit"/> </xsl:template> <!-- main event --> <xsl:template match="unit"> <xsl:variable name="parserclassname" select="concat('FICS', @class, 'Parser')" /> <xsl:variable name="classname" select="concat($parserclassname, 'Test')" /> <xsl:variable name="filename" select="concat($classname, '.java')" /> <!-- show the filename so we can capture in a log and delete later --> <xsl:value-of select="$filename"/><xsl:text> </xsl:text> <redirect:write select="$filename">/* /* * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2003 J. Varsoke <jva...@gh...> * All rights reserved. * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package ictk.boardgame.chess.net.ics.fics.event; import ictk.boardgame.chess.net.ics.event.*; import ictk.boardgame.chess.net.ics.*; import ictk.util.Log; import java.util.regex.*; import java.io.IOException; import junit.framework.*; public class <xsl:value-of select="$classname"/> extends ParserTest { ICS<xsl:value-of select="@event"/>Event evt; public <xsl:value-of select="$classname"/> () throws IOException { super("ictk.boardgame.chess.net.ics.fics.event"); } public void setUp () { parser = <xsl:value-of select="$parserclassname"/>.getInstance(); //debug = true; } public void tearDown () { evt = null; parser = null; } <xsl:apply-templates select="test"/> //inherited/////////////////////////////////////////////////////////// public void testParseAll () { //debug=true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { super.testParseAll(); } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } ////////////////////////////////////////////////////////////////////// public void testNative () { //debug=true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { super.testNative(); } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } } </redirect:write> </xsl:template> <xsl:template match="test"> ////////////////////////////////////////////////////////////////////// public void test<xsl:value-of select="@name"/> () { //debug = true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { evt = (ICS<xsl:value-of select="../@event"/>Event) <!-- -->parser.createICSEvent(mesg[<xsl:value-of select="@iochunk"/>]); assertTrue(evt != null); //begin test <xsl:apply-templates select="code" mode="test"/> //end test } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } </xsl:template> <xsl:template match="code" mode="test"> <xsl:if test="@format='java'"> <xsl:value-of select="."/> </xsl:if> </xsl:template> </xsl:stylesheet> --- NEW FILE: unitTest.dtd --- <?xml version="1.0" encoding="utf-8"?> <!-- * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: unitTest.dtd,v 1.1 2003/08/26 20:16:01 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!ELEMENT unitTest (unit*)> <!ATTLIST unitTest xmlns:unittest CDATA "http://ictk.sourceforge.net/test/unittest" > <!ELEMENT unit (description?, test*)> <!ATTLIST unit id ID #REQUIRED class NMTOKEN #REQUIRED event NMTOKEN #IMPLIED type NMTOKEN #IMPLIED > <!ELEMENT description (#PCDATA)*> <!ATTLIST description xml:space (default | preserve) 'preserve' > <!ELEMENT test (description?, code?)> <!ATTLIST test name NMTOKEN #REQUIRED iochunk NMTOKEN #IMPLIED > <!ELEMENT code (#PCDATA)> <!ATTLIST code format NOTATION (java) #REQUIRED xml:space (default | preserve) 'preserve' > <!NOTATION java SYSTEM "http://java.sun.com"> <!-- ? --> Index: AllTests.java =================================================================== RCS file: /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event/AllTests.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AllTests.java 24 Aug 2003 01:48:44 -0000 1.3 --- AllTests.java 26 Aug 2003 20:16:01 -0000 1.4 *************** *** 45,53 **** suite.addTest(new TestSuite(FICSPlayerNotificationParserTest.class)); suite.addTest(new TestSuite(FICSSeekAdParserTest.class)); - /* suite.addTest(new TestSuite(FICSSeekAdReadableParserTest.class)); suite.addTest(new TestSuite(FICSSeekClearParserTest.class)); suite.addTest(new TestSuite(FICSSeekRemoveParserTest.class)); - */ suite.addTest(new TestSuite(FICSShoutParserTest.class)); suite.addTest(new TestSuite(FICSTellParserTest.class)); --- 45,51 ---- --- FICSBoardUpdateStyle12ParserTest.java DELETED --- --- FICSChannelParserTest.java DELETED --- --- FICSGameCreatedParserTest.java DELETED --- --- FICSGameNotificationParserTest.java DELETED --- --- FICSKibitzParserTest.java DELETED --- --- FICSMoveListParserTest.java DELETED --- --- FICSPlayerConnectionParserTest.java DELETED --- --- FICSPlayerNotificationParserTest.java DELETED --- --- FICSSeekAdParserTest.java DELETED --- --- FICSSeekAdReadableParserTest.java DELETED --- --- FICSSeekClearParserTest.java DELETED --- --- FICSSeekRemoveParserTest.java DELETED --- --- FICSShoutParserTest.java DELETED --- --- FICSTellParserTest.java DELETED --- --- makeTest.pl DELETED --- --- testTemplate.txt DELETED --- |
|
From: <jva...@us...> - 2003-08-26 20:16:12
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event
In directory sc8-pr-cvs1:/tmp/cvs-serv24797/src/ictk/boardgame/chess/net/ics/event
Modified Files:
seekAd.xml
Log Message:
replaced all fics/event/Tests with xslt generated test files.
Index: seekAd.xml
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/seekAd.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** seekAd.xml 24 Aug 2003 09:53:00 -0000 1.2
--- seekAd.xml 26 Aug 2003 20:16:01 -0000 1.3
***************
*** 127,131 ****
\s
rr=(\d+) <!-- low range -->
! -(\d+) <!-- high range -->
\s
a=([tf]) <!-- automatic / manual -->
--- 127,131 ----
\s
rr=(\d+) <!-- low range -->
! -(\d+) <!-- high range -->
\s
a=([tf]) <!-- automatic / manual -->
***************
*** 172,176 ****
//automatic/manual
! evt.setManual(m.group(14).charAt(0) == 't');
//restricted by formula
--- 172,176 ----
//automatic/manual
! evt.setManual(m.group(14).charAt(0) == 'f');
//restricted by formula
|
|
From: <jva...@us...> - 2003-08-26 00:58:41
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/ui/cli In directory sc8-pr-cvs1:/tmp/cvs-serv5039/src/ictk/boardgame/chess/net/ics/ui/cli Modified Files: ANSIConsole.java Log Message: added ICSSeekAdReadable Index: ANSIConsole.java =================================================================== RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/ui/cli/ANSIConsole.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ANSIConsole.java 24 Aug 2003 07:16:36 -0000 1.7 --- ANSIConsole.java 24 Aug 2003 09:53:01 -0000 1.8 *************** *** 112,118 **** break; - /* case ICSEvent.SEEK_AD_READABLE_EVENT: - */ case ICSEvent.GAME_NOTIFICATION_EVENT: prefix = ESC + BLUE; --- 112,116 ---- |
|
From: <jva...@us...> - 2003-08-25 01:29:08
|
Update of /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event In directory sc8-pr-cvs1:/tmp/cvs-serv9226/test/ictk/boardgame/chess/net/ics/fics/event Added Files: FICSSeekRemoveParserTest.java Log Message: Added ICSSeekRemoveEvent --- NEW FILE: FICSSeekRemoveParserTest.java --- /* * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: FICSSeekRemoveParserTest.java,v 1.1 2003/08/25 01:29:01 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package ictk.boardgame.chess.net.ics.fics.event; import ictk.boardgame.chess.net.ics.event.*; import ictk.boardgame.chess.net.ics.*; import ictk.util.Log; import java.util.regex.*; import java.io.IOException; import junit.framework.*; public class FICSSeekRemoveParserTest extends ParserTest { ICSSeekRemoveEvent evt; public FICSSeekRemoveParserTest () throws IOException { super("ictk.boardgame.chess.net.ics.fics.event"); } public void setUp () { parser = FICSSeekRemoveParser.getInstance(); //debug = true; } public void tearDown () { evt = null; parser = null; } ////////////////////////////////////////////////////////////////////// public void testMessage0 () { //debug = true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { evt = (ICSSeekRemoveEvent) parser.createICSEvent(mesg[0]); assertTrue(evt != null); //begin test //end test } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } //inherited/////////////////////////////////////////////////////////// public void testParseAll () { //debug=true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { super.testParseAll(); } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } ////////////////////////////////////////////////////////////////////// public void testNative () { //debug=true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { super.testNative(); } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } } |
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event In directory sc8-pr-cvs1:/tmp/cvs-serv9226/src/ictk/boardgame/chess/net/ics/event Modified Files: ICSSeekClearEvent.java ICSSeekRemoveEvent.java parser.xsl parserCommon.xml Added Files: seekRemove.xml Log Message: Added ICSSeekRemoveEvent --- NEW FILE: seekRemove.xml --- <?xml version="1.0" encoding="utf-8" standalone="no"?> <!-- * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: seekRemove.xml,v 1.1 2003/08/25 01:29:00 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!DOCTYPE icsevtml SYSTEM "icsevtml.dtd" [ <!ENTITY common SYSTEM "parserCommon.xml"> ]> <icsevtml> <!-- channel............................................................--> <event id="seekRemove" class="SeekRemove" enum="SEEK_REMOVE" > <description> This message from the server indicates that a number of seek ads should be cleared from the client's records. The server does not keep track of which seeks you know about though. </description> <member id="seekRemove:ads" typeref="int[]" varname="ads" functname="Ads" /> <!--pin parser--> <parser id="seekRemove:parser" name="SeekRemove" protocol="FICS" extends="ICSEventParser" detectFake="no"> <!-- regex --> <regex> <sr> ((?:\s\d+)+) <!-- multiple numbers to remove --> </regex> <!-- assignMatches --> <assignMatches format="java"> StringTokenizer st = new StringTokenizer(m.group(2)); int[] ads = new int[st.countTokens()]; int i = 0; try { while (st.hasMoreTokens()) { ads[i] = Integer.parseInt(st.nextToken()); i++; } } catch (NumberFormatException e) { Log.error(Log.PROG_WARNING, "Can't parse ads[" + i + "] " + "of " + m.group(0)); evt.setEventType(ICSEvent.UNKNOWN_EVENT); evt.setMessage(m.group(0)); if (Log.debug) Log.debug(ICSEventParser.DEBUG, "regex", m); return; } evt.setAds(ads); </assignMatches> <!-- toNative --> <toNative avgLength="5"> <code format="java"> int[] ads = evt.getAds(); sb.append("<sr>"); for (int i=0; i < ads.length; i++) sb.append(" ") .append(ads[i]); </code> </toNative> </parser> </event> &common; </icsevtml> Index: ICSSeekClearEvent.java =================================================================== RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/ICSSeekClearEvent.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ICSSeekClearEvent.java 24 Aug 2003 18:01:47 -0000 1.3 --- ICSSeekClearEvent.java 25 Aug 2003 01:29:00 -0000 1.4 *************** *** 27,31 **** * This file was auto-generated * by $Id$ ! * on Sun Aug 24 12:53:05 EST 2003 *--------------------------------------------------------------------------*/ --- 27,31 ---- * This file was auto-generated * by $Id$ ! * on Sun Aug 24 18:48:29 EST 2003 *--------------------------------------------------------------------------*/ Index: ICSSeekRemoveEvent.java =================================================================== RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/ICSSeekRemoveEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ICSSeekRemoveEvent.java 13 May 2003 16:01:39 -0000 1.2 --- ICSSeekRemoveEvent.java 25 Aug 2003 01:29:00 -0000 1.3 *************** *** 2,10 **** * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net ! * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * - * $Id$ - * * This file is part of ICTK. * --- 2,8 ---- * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net ! * Copyright (C) 2003 J. Varsoke <jva...@gh...> * All rights reserved. * * This file is part of ICTK. * *************** *** 25,74 **** package ictk.boardgame.chess.net.ics.event; import ictk.boardgame.chess.net.ics.*; import java.util.regex.*; import java.io.IOException; - import java.util.StringTokenizer; ! public class ICSSeekRemoveEvent ! extends ICSEvent ! implements ICSSeekEvent { ! public static final int SEEK_REMOVE_EVENT = ICSEvent.SEEK_REMOVE_EVENT; ! //instance///////////////////////////////////////////////////////////// protected int[] ads; public ICSSeekRemoveEvent () { super(SEEK_REMOVE_EVENT); } ! //getters and setters////////////////////////////////////////////////////// ! public int getAd (int index) { ! return ads[index]; ! } ! ! public void setAd (int index, int num) { ! ads[index] = num; ! } ! ! public int length () { ! return ads.length; } public void setAds (int[] ads) { this.ads = ads; } - public int[] getAds () { - return ads; - } public String getReadable () { ! StringBuffer sb = new StringBuffer(20); ! sb.append("<SeekRemove> "); ! for (int i=0; i < ads.length; i++) ! sb.append(ads[i]); ! ! return sb.toString(); } } --- 23,76 ---- package ictk.boardgame.chess.net.ics.event; + + /*--------------------------------------------------------------------------* + * This file was auto-generated + * by $Id$ + * on Sun Aug 24 20:18:58 EST 2003 + *--------------------------------------------------------------------------*/ + import ictk.boardgame.chess.net.ics.*; + import ictk.boardgame.chess.net.ics.fics.event.*; + import ictk.util.Log; import java.util.regex.*; import java.io.IOException; ! /** ! * This message from the server indicates that a number of seek ads ! * should be cleared from the client's records. The server does not ! * keep track of which seeks you know about though. ! */ ! public class ICSSeekRemoveEvent extends ICSEvent { ! ! //static initializer///////////////////////////////////////////////////// ! protected static final int SEEK_REMOVE_EVENT = ICSEvent.SEEK_REMOVE_EVENT; ! ! ! ! //instance vars////////////////////////////////////////////////////////// protected int[] ads; + + //constructors/////////////////////////////////////////////////////////// public ICSSeekRemoveEvent () { super(SEEK_REMOVE_EVENT); } ! //assessors///////////////////////////////////////////////////////////// ! public int[] getAds () { ! return ads; } + //mutators////////////////////////////////////////////////////////////// public void setAds (int[] ads) { this.ads = ads; } + //readable////////////////////////////////////////////////////////////// public String getReadable () { ! return FICSSeekRemoveParser.getInstance().toNative(this); } } Index: parser.xsl =================================================================== RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/parser.xsl,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** parser.xsl 24 Aug 2003 18:01:47 -0000 1.10 --- parser.xsl 25 Aug 2003 01:29:00 -0000 1.11 *************** *** 105,108 **** --- 105,109 ---- import ictk.util.Log; + import java.util.*; import java.util.regex.*; import java.io.IOException; Index: parserCommon.xml =================================================================== RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/event/parserCommon.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** parserCommon.xml 20 Aug 2003 21:12:18 -0000 1.4 --- parserCommon.xml 25 Aug 2003 01:29:00 -0000 1.5 *************** *** 38,41 **** --- 38,48 ---- </membertype> + <!-- int[] --> + <membertype id="int[]" + type="int[]" + varname="numbers" + functname="Numbers"> + </membertype> + <!-- boolean --> <membertype id="boolean" |
|
From: <jva...@us...> - 2003-08-25 01:29:08
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics
In directory sc8-pr-cvs1:/tmp/cvs-serv9226/src/ictk/boardgame/chess/net/ics/fics
Modified Files:
FICSProtocolHandler.java
Log Message:
Added ICSSeekRemoveEvent
Index: FICSProtocolHandler.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics/FICSProtocolHandler.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** FICSProtocolHandler.java 24 Aug 2003 23:36:07 -0000 1.16
--- FICSProtocolHandler.java 25 Aug 2003 01:29:00 -0000 1.17
***************
*** 197,201 ****
int i = 0;
//eventFactories = new ICSEventParser[16];
! eventFactories = new ICSEventParser[14];
eventFactories[i++] = FICSBoardUpdateStyle12Parser.getInstance();
eventFactories[i++] = FICSMoveListParser.getInstance();
--- 197,201 ----
int i = 0;
//eventFactories = new ICSEventParser[16];
! eventFactories = new ICSEventParser[15];
eventFactories[i++] = FICSBoardUpdateStyle12Parser.getInstance();
eventFactories[i++] = FICSMoveListParser.getInstance();
***************
*** 211,214 ****
--- 211,215 ----
eventFactories[i++] = FICSSeekClearParser.getInstance();
eventFactories[i++] = FICSSeekAdParser.getInstance();
+ eventFactories[i++] = FICSSeekRemoveParser.getInstance();
eventFactories[i++] = FICSSeekAdReadableParser.getInstance();
|
|
From: <jva...@us...> - 2003-08-25 01:29:07
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/ui/cli In directory sc8-pr-cvs1:/tmp/cvs-serv9226/src/ictk/boardgame/chess/net/ics/ui/cli Modified Files: ANSIConsole.java Log Message: Added ICSSeekRemoveEvent Index: ANSIConsole.java =================================================================== RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/ui/cli/ANSIConsole.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ANSIConsole.java 24 Aug 2003 18:01:47 -0000 1.9 --- ANSIConsole.java 25 Aug 2003 01:29:01 -0000 1.10 *************** *** 99,105 **** break; - /* case ICSEvent.SEEK_REMOVE_EVENT: - */ case ICSEvent.SEEK_CLEAR_EVENT: case ICSEvent.SEEK_AD_EVENT: --- 99,103 ---- |
|
From: <jva...@us...> - 2003-08-24 23:36:10
|
Update of /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics
In directory sc8-pr-cvs1:/tmp/cvs-serv26730/src/ictk/boardgame/chess/net/ics/fics
Modified Files:
FICSProtocolHandler.java
Log Message:
SeekAdClear is followed by SeekAds, FICSProtocolHandler now knows to parse
the Ads too.
Index: FICSProtocolHandler.java
===================================================================
RCS file: /cvsroot/ictk/ictk/src/ictk/boardgame/chess/net/ics/fics/FICSProtocolHandler.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** FICSProtocolHandler.java 24 Aug 2003 18:01:47 -0000 1.15
--- FICSProtocolHandler.java 24 Aug 2003 23:36:07 -0000 1.16
***************
*** 209,215 ****
eventFactories[i++] = FICSPlayerNotificationParser.getInstance();
eventFactories[i++] = FICSGameNotificationParser.getInstance();
eventFactories[i++] = FICSSeekAdParser.getInstance();
eventFactories[i++] = FICSSeekAdReadableParser.getInstance();
- eventFactories[i++] = FICSSeekClearParser.getInstance();
router = new ICSEventRouter();
--- 209,215 ----
eventFactories[i++] = FICSPlayerNotificationParser.getInstance();
eventFactories[i++] = FICSGameNotificationParser.getInstance();
+ eventFactories[i++] = FICSSeekClearParser.getInstance();
eventFactories[i++] = FICSSeekAdParser.getInstance();
eventFactories[i++] = FICSSeekAdReadableParser.getInstance();
router = new ICSEventRouter();
***************
*** 498,502 ****
--- 498,505 ----
buffer.limit(buffer.position() - prompt.length);
buffer.rewind();
+
+ //send to parser for processing
parse(buffer);
+
buffer.clear();
ptr = 0;
***************
*** 645,649 ****
}
! /* sendCommand () *********************************************************/
/** send a command to the server.
*/
--- 648,652 ----
}
! /* sendCommand ************************************************************/
/** send a command to the server.
*/
***************
*** 663,667 ****
}
! /* parse () **************************************************************/
/** The 'datagram' or message chunk has already been establish, now we
* just gotta figure out what the message is and send it to the right
--- 666,670 ----
}
! /* parse *****************************************************************/
/** The 'datagram' or message chunk has already been establish, now we
* just gotta figure out what the message is and send it to the right
***************
*** 674,680 ****
for (int i=0; i < eventFactories.length && !found; i++) {
! if ((icsEvent = eventFactories[i].createICSEvent(str)) != null) {
icsEvent.setServer(this);
found = true;
router.dispatch(icsEvent);
}
--- 677,706 ----
for (int i=0; i < eventFactories.length && !found; i++) {
!
! if ((matcher = eventFactories[i].match(str)) != null) {
! icsEvent = eventFactories[i].createICSEvent(matcher);
! assert icsEvent != null : "parser matched, but event null?";
icsEvent.setServer(this);
+ router.dispatch(icsEvent);
+
found = true;
+ }
+ }
+
+ //SEEK_CLEAR is followed by many seek ads usually
+ //SEEK_ADs are not necessarily one per chunk
+ CharSequence more = str;
+ while (matcher != null
+ && icsEvent != null
+ && (icsEvent.getEventType() == ICSEvent.SEEK_CLEAR_EVENT
+ || icsEvent.getEventType() == ICSEvent.SEEK_AD_EVENT)) {
+
+ matcher = FICSSeekAdParser.getInstance().match(
+ more = more.subSequence(matcher.end(), more.length()));
+
+ if (matcher != null) {
+ icsEvent = FICSSeekAdParser.getInstance().createICSEvent(matcher);
+ assert icsEvent != null : "parser matched, but event null?";
+ icsEvent.setServer(this);
router.dispatch(icsEvent);
}
|
|
From: <jva...@us...> - 2003-08-24 18:35:39
|
Update of /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event In directory sc8-pr-cvs1:/tmp/cvs-serv5039/test/ictk/boardgame/chess/net/ics/fics/event Added Files: FICSSeekAdReadableParserTest.java Log Message: added ICSSeekAdReadable --- NEW FILE: FICSSeekAdReadableParserTest.java --- /* * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: FICSSeekAdReadableParserTest.java,v 1.1 2003/08/24 09:53:01 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package ictk.boardgame.chess.net.ics.fics.event; import ictk.boardgame.chess.net.ics.event.*; import ictk.boardgame.chess.net.ics.*; import ictk.util.Log; import java.util.regex.*; import java.io.IOException; import junit.framework.*; public class FICSSeekAdReadableParserTest extends ParserTest { ICSSeekAdEvent evt; public FICSSeekAdReadableParserTest () throws IOException { super("ictk.boardgame.chess.net.ics.fics.event"); } public void setUp () { parser = FICSSeekAdReadableParser.getInstance(); //debug = true; } public void tearDown () { evt = null; parser = null; } ////////////////////////////////////////////////////////////////////// public void testMessage0 () { //debug = true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { evt = (ICSSeekAdEvent) parser.createICSEvent(mesg[0]); assertTrue(evt != null); //begin test //end test } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } //inherited/////////////////////////////////////////////////////////// public void testParseAll () { //debug=true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { super.testParseAll(); } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } ////////////////////////////////////////////////////////////////////// public void testNative () { //debug=true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { super.testNative(); } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } } |
|
From: <jva...@us...> - 2003-08-24 18:35:33
|
Update of /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event/data
In directory sc8-pr-cvs1:/tmp/cvs-serv5039/test/ictk/boardgame/chess/net/ics/fics/event/data
Modified Files:
FICSHistoryParser.data FICSSeekAdReadableParserTest.data
Log Message:
added ICSSeekAdReadable
Index: FICSHistoryParser.data
===================================================================
RCS file: /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event/data/FICSHistoryParser.data,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FICSHistoryParser.data 24 Aug 2003 01:48:45 -0000 1.1
--- FICSHistoryParser.data 24 Aug 2003 09:53:01 -0000 1.2
***************
*** 1,3 ****
--- 1,10 ----
##$Id$
+
+ History for CyberTick:
+ Opponent Type ECO End Date
+ 5: + 1735 W 1059 cesarCR [ br 5 12] C53 Res Thu Oct 24, 16:32 EST 2002
+ 6: - 0 B 0 TibetianTick [ uu 0 0] B00 Res Sat Nov 2, 16:23 EST 2002
+ ##
+
History for TibetianTick:
Opponent Type ECO End Date
Index: FICSSeekAdReadableParserTest.data
===================================================================
RCS file: /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event/data/FICSSeekAdReadableParserTest.data,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FICSSeekAdReadableParserTest.data 24 Aug 2003 01:48:45 -0000 1.1
--- FICSSeekAdReadableParserTest.data 24 Aug 2003 09:53:02 -0000 1.2
***************
*** 1,4 ****
##$Id$
! mrbishop (1701) seeking 30 15 rated [white] standard m f play 10
##
GuestJMWQ (++++) seeking 2 12 unrated blitz ("play 95" to respond)
--- 1,4 ----
##$Id$
! mrbishop (1701) seeking 30 15 rated standard [white] m f ("play 10" to respond)
##
GuestJMWQ (++++) seeking 2 12 unrated blitz ("play 95" to respond)
|