Format all code, add editorconfig
This commit is contained in:
parent
a1dff2cb8d
commit
3faced7068
52 changed files with 2011 additions and 1918 deletions
11
.editorconfig
Normal file
11
.editorconfig
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.iml]
|
||||||
|
indent_size = 2
|
4
.github/README.md
vendored
4
.github/README.md
vendored
|
@ -3,9 +3,11 @@
|
||||||
This is a fork of [Jaim](https://jaimlib.sourceforge.net/), a Java library that implements the AOL TOC protocol.
|
This is a fork of [Jaim](https://jaimlib.sourceforge.net/), a Java library that implements the AOL TOC protocol.
|
||||||
|
|
||||||
This fork features various improvements on the original Jaim:
|
This fork features various improvements on the original Jaim:
|
||||||
|
|
||||||
- Support for chat invites
|
- Support for chat invites
|
||||||
|
|
||||||
## Original README
|
## Original README
|
||||||
|
|
||||||
```
|
```
|
||||||
Readme.txt for Jaimlib
|
Readme.txt for Jaimlib
|
||||||
----------------------
|
----------------------
|
||||||
|
@ -21,4 +23,4 @@ Use ctrl-c to end the test
|
||||||
For more information see http://jaimlib.sourceforge.net
|
For more information see http://jaimlib.sourceforge.net
|
||||||
|
|
||||||
wilko@users.sourceforge.net
|
wilko@users.sourceforge.net
|
||||||
```
|
```
|
||||||
|
|
62
build.xml
62
build.xml
|
@ -6,11 +6,11 @@
|
||||||
<!-- for the classes in your application. -->
|
<!-- for the classes in your application. -->
|
||||||
<project basedir="." default="all" name="jaimlib">
|
<project basedir="." default="all" name="jaimlib">
|
||||||
|
|
||||||
<target name="init">
|
<target name="init">
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target depends="init" name="compile">
|
<target depends="init" name="compile">
|
||||||
<mkdir dir="build"/>
|
<mkdir dir="build"/>
|
||||||
<!-- Both srcdir and destdir should be package roots. -->
|
<!-- Both srcdir and destdir should be package roots. -->
|
||||||
<!-- They could be different of course; in that case NetBeans can also be set -->
|
<!-- They could be different of course; in that case NetBeans can also be set -->
|
||||||
<!-- up to compile to a different filesystem in the same way; see Compiler Types: -->
|
<!-- up to compile to a different filesystem in the same way; see Compiler Types: -->
|
||||||
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
<target depends="init,compile" name="jar">
|
<target depends="init,compile" name="jar">
|
||||||
<mkdir dir="lib"/>
|
<mkdir dir="lib"/>
|
||||||
<copy todir="build">
|
<copy todir="build">
|
||||||
<fileset dir="src">
|
<fileset dir="src">
|
||||||
<include name="**/*.properties"/>
|
<include name="**/*.properties"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
<jar basedir="build" compress="true" jarfile="lib/jaimlib.jar">
|
<jar basedir="build" compress="true" jarfile="lib/jaimlib.jar">
|
||||||
<exclude name="**/*.java"/>
|
<exclude name="**/*.java"/>
|
||||||
<exclude name="**/jaimtest/**"/>
|
<exclude name="**/jaimtest/**"/>
|
||||||
</jar>
|
</jar>
|
||||||
|
@ -33,10 +33,10 @@
|
||||||
|
|
||||||
<target depends="init,compile" name="jartest">
|
<target depends="init,compile" name="jartest">
|
||||||
<mkdir dir="lib"/>
|
<mkdir dir="lib"/>
|
||||||
<jar basedir="build" compress="true" jarfile="lib/jaimtest.jar">
|
<jar basedir="build" compress="true" jarfile="lib/jaimtest.jar">
|
||||||
<manifest>
|
<manifest>
|
||||||
<attribute name="Main-Class" value="com.wilko.jaimtest.JaimTest"/>
|
<attribute name="Main-Class" value="com.wilko.jaimtest.JaimTest"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
<exclude name="**/*.java"/>
|
<exclude name="**/*.java"/>
|
||||||
</jar>
|
</jar>
|
||||||
</target>
|
</target>
|
||||||
|
@ -55,29 +55,29 @@
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target depends="init" description="Clean all build products." name="clean">
|
<target depends="init" description="Clean all build products." name="clean">
|
||||||
<delete dir="doc/apidoc" includeEmptyDirs="true"/>
|
<delete dir="doc/apidoc" includeEmptyDirs="true"/>
|
||||||
<delete dir="build" includeEmptyDirs="true"/>
|
<delete dir="build" includeEmptyDirs="true"/>
|
||||||
<delete dir="lib" includeEmptyDirs="true"/>
|
<delete dir="lib" includeEmptyDirs="true"/>
|
||||||
<delete>
|
<delete>
|
||||||
<fileset dir="src" includes="**/*.class"/>
|
<fileset dir="src" includes="**/*.class"/>
|
||||||
</delete>
|
</delete>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target depends="javadoc,compile,jar,jartest" name="dist">
|
<target depends="javadoc,compile,jar,jartest" name="dist">
|
||||||
<delete>
|
<delete>
|
||||||
<fileset dir="." includes="jaimlib.tar*"/>
|
<fileset dir="." includes="jaimlib.tar*"/>
|
||||||
</delete>
|
</delete>
|
||||||
<mkdir dir="jaimlib"/>
|
<mkdir dir="jaimlib"/>
|
||||||
<mkdir dir="jaimlib/lib"/>
|
<mkdir dir="jaimlib/lib"/>
|
||||||
<mkdir dir="jaimlib/doc"/>
|
<mkdir dir="jaimlib/doc"/>
|
||||||
<copy todir="jaimlib">
|
<copy todir="jaimlib">
|
||||||
<fileset dir="." includes="license.txt"/>
|
<fileset dir="." includes="license.txt"/>
|
||||||
<fileset dir="." includes="build.xml"/>
|
<fileset dir="." includes="build.xml"/>
|
||||||
<fileset dir="." includes="changes.txt"/>
|
<fileset dir="." includes="changes.txt"/>
|
||||||
<fileset dir="." includes="readme.txt"/>
|
<fileset dir="." includes="readme.txt"/>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="jaimlib/lib">
|
<copy todir="jaimlib/lib">
|
||||||
<fileset dir="lib"/>
|
<fileset dir="lib"/>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="jaimlib/doc">
|
<copy todir="jaimlib/doc">
|
||||||
<fileset dir="doc"/>
|
<fileset dir="doc"/>
|
||||||
|
@ -89,20 +89,20 @@
|
||||||
</target>
|
</target>
|
||||||
<target depends="javadoc,compile,jar,jartest" name="srcdist">
|
<target depends="javadoc,compile,jar,jartest" name="srcdist">
|
||||||
<delete>
|
<delete>
|
||||||
<fileset dir="." includes="jaimlibsrc.tar*"/>
|
<fileset dir="." includes="jaimlibsrc.tar*"/>
|
||||||
</delete>
|
</delete>
|
||||||
<mkdir dir="jaimlib"/>
|
<mkdir dir="jaimlib"/>
|
||||||
<mkdir dir="jaimlib/lib"/>
|
<mkdir dir="jaimlib/lib"/>
|
||||||
<mkdir dir="jaimlib/doc"/>
|
<mkdir dir="jaimlib/doc"/>
|
||||||
<mkdir dir="jaimlib/src"/>
|
<mkdir dir="jaimlib/src"/>
|
||||||
<copy todir="jaimlib">
|
<copy todir="jaimlib">
|
||||||
<fileset dir="." includes="license.txt"/>
|
<fileset dir="." includes="license.txt"/>
|
||||||
<fileset dir="." includes="build.xml"/>
|
<fileset dir="." includes="build.xml"/>
|
||||||
<fileset dir="." includes="changes.txt"/>
|
<fileset dir="." includes="changes.txt"/>
|
||||||
<fileset dir="." includes="readme.txt"/>
|
<fileset dir="." includes="readme.txt"/>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="jaimlib/lib">
|
<copy todir="jaimlib/lib">
|
||||||
<fileset dir="lib"/>
|
<fileset dir="lib"/>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="jaimlib/doc">
|
<copy todir="jaimlib/doc">
|
||||||
<fileset dir="doc"/>
|
<fileset dir="doc"/>
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/lib" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -25,64 +25,79 @@
|
||||||
|
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/** This is a buddy object that holds the buddy's name and other
|
/**
|
||||||
|
* This is a buddy object that holds the buddy's name and other
|
||||||
* information about a buddy.
|
* information about a buddy.
|
||||||
|
*
|
||||||
* @author Brett Humphreys
|
* @author Brett Humphreys
|
||||||
*/
|
*/
|
||||||
public class Buddy {
|
public class Buddy {
|
||||||
/** Name of the buddy */
|
/**
|
||||||
private String buddyName;
|
* Name of the buddy
|
||||||
|
*/
|
||||||
/** Permit value */
|
private final String buddyName;
|
||||||
private boolean permit;
|
|
||||||
|
/**
|
||||||
/** deny value */
|
* Permit value
|
||||||
private boolean deny;
|
*/
|
||||||
|
private boolean permit;
|
||||||
/** Constructor that sets the buddy name
|
|
||||||
* @param name the name of this buddy.
|
/**
|
||||||
*/
|
* deny value
|
||||||
public Buddy ( String name )
|
*/
|
||||||
{
|
private boolean deny;
|
||||||
buddyName = name;
|
|
||||||
}
|
/**
|
||||||
|
* Constructor that sets the buddy name
|
||||||
/** Gets the buddy name
|
*
|
||||||
* @return buddy name
|
* @param name the name of this buddy.
|
||||||
*/
|
*/
|
||||||
public String getName()
|
public Buddy(String name) {
|
||||||
{
|
buddyName = name;
|
||||||
return buddyName;
|
}
|
||||||
}
|
|
||||||
/** Sets the permit value
|
/**
|
||||||
* @param permitVal what to set permit to
|
* Gets the buddy name
|
||||||
*/
|
*
|
||||||
public void setPermit( boolean permitVal )
|
* @return buddy name
|
||||||
{
|
*/
|
||||||
permit = permitVal;
|
public String getName() {
|
||||||
}
|
return buddyName;
|
||||||
|
}
|
||||||
/** Gets the permit value
|
|
||||||
* @return permit value
|
/**
|
||||||
*/
|
* Gets the permit value
|
||||||
public boolean getPermit( )
|
*
|
||||||
{
|
* @return permit value
|
||||||
return permit;
|
*/
|
||||||
}
|
public boolean getPermit() {
|
||||||
|
return permit;
|
||||||
/** Sets the deny value
|
}
|
||||||
* @param denyVal what to set deny to
|
|
||||||
*/
|
/**
|
||||||
public void setDeny( boolean denyVal )
|
* Sets the permit value
|
||||||
{
|
*
|
||||||
deny = denyVal;
|
* @param permitVal what to set permit to
|
||||||
}
|
*/
|
||||||
|
public void setPermit(boolean permitVal) {
|
||||||
/** Gets the deny value
|
permit = permitVal;
|
||||||
* @return deny value
|
}
|
||||||
*/
|
|
||||||
public boolean getDeny( )
|
/**
|
||||||
{
|
* Gets the deny value
|
||||||
return deny;
|
*
|
||||||
}
|
* @return deny value
|
||||||
}
|
*/
|
||||||
|
public boolean getDeny() {
|
||||||
|
return deny;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the deny value
|
||||||
|
*
|
||||||
|
* @param denyVal what to set deny to
|
||||||
|
*/
|
||||||
|
public void setDeny(boolean denyVal) {
|
||||||
|
deny = denyVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -28,12 +28,15 @@ package com.wilko.jaim;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
/** A BuddyUpdateTocResponse is delivered to a {@link JaimEventListener } when a buddy update is received from the TOC server
|
/**
|
||||||
|
* A BuddyUpdateTocResponse is delivered to a {@link JaimEventListener } when a buddy update is received from the TOC server
|
||||||
|
*
|
||||||
* @author paulw
|
* @author paulw
|
||||||
* @version $Revision: 1.7 $
|
* @version $Revision: 1.7 $
|
||||||
*/
|
*/
|
||||||
public class BuddyUpdateTocResponse extends TocResponse implements TocResponseHandler {
|
public class BuddyUpdateTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
public static String RESPONSE_TYPE = "UPDATE_BUDDY";
|
||||||
private String buddyName;
|
private String buddyName;
|
||||||
private boolean online;
|
private boolean online;
|
||||||
private int evil;
|
private int evil;
|
||||||
|
@ -44,167 +47,165 @@ public class BuddyUpdateTocResponse extends TocResponse implements TocResponseHa
|
||||||
private boolean confirmed;
|
private boolean confirmed;
|
||||||
private Date signonTime;
|
private Date signonTime;
|
||||||
private boolean away;
|
private boolean away;
|
||||||
|
|
||||||
public static String RESPONSE_TYPE="UPDATE_BUDDY";
|
/**
|
||||||
|
* Creates new BuddyUpdateTocResponse
|
||||||
/** Creates new BuddyUpdateTocResponse */
|
*/
|
||||||
public BuddyUpdateTocResponse() {
|
public BuddyUpdateTocResponse() {
|
||||||
buddyName="";
|
buddyName = "";
|
||||||
online=false;
|
online = false;
|
||||||
evil=0;
|
evil = 0;
|
||||||
idleTime=0;
|
idleTime = 0;
|
||||||
onAOL=false;
|
onAOL = false;
|
||||||
unconfirmed=false;
|
unconfirmed = false;
|
||||||
admin=false;
|
admin = false;
|
||||||
confirmed=false;
|
confirmed = false;
|
||||||
away=false;
|
away = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The parseString method is used to populate the fields of this class from a Buddy Update string from the TOC server
|
/**
|
||||||
|
* The parseString method is used to populate the fields of this class from a Buddy Update string from the TOC server
|
||||||
|
*
|
||||||
* @param str The String containing the buddy update
|
* @param str The String containing the buddy update
|
||||||
*/
|
*/
|
||||||
public TocResponse parseString(java.lang.String str) {
|
public TocResponse parseString(java.lang.String str) {
|
||||||
BuddyUpdateTocResponse tr=new BuddyUpdateTocResponse();
|
BuddyUpdateTocResponse tr = new BuddyUpdateTocResponse();
|
||||||
tr.doParse(str);
|
tr.doParse(str);
|
||||||
return(tr);
|
return (tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
private void doParse(String str) {
|
||||||
{
|
cmd = str;
|
||||||
cmd=str;
|
StringTokenizer st = new StringTokenizer(str, ":");
|
||||||
StringTokenizer st=new StringTokenizer(str,":");
|
|
||||||
|
|
||||||
st.nextToken();
|
st.nextToken();
|
||||||
buddyName=st.nextToken();
|
buddyName = st.nextToken();
|
||||||
String onlineStr=st.nextToken();
|
String onlineStr = st.nextToken();
|
||||||
if (onlineStr.equals("T"))
|
online = onlineStr.equals("T");
|
||||||
{
|
|
||||||
online=true;
|
evil = Integer.parseInt(st.nextToken());
|
||||||
}
|
long signon = Long.parseLong(st.nextToken());
|
||||||
else
|
signonTime = new Date(signon * 1000);
|
||||||
{
|
idleTime = Integer.parseInt(st.nextToken());
|
||||||
online=false;
|
String userclass = st.nextToken();
|
||||||
}
|
|
||||||
|
|
||||||
evil=Integer.parseInt(st.nextToken());
|
|
||||||
long signon=Long.parseLong(st.nextToken());
|
|
||||||
signonTime=new Date(signon*1000);
|
|
||||||
idleTime=Integer.parseInt(st.nextToken());
|
|
||||||
String userclass=st.nextToken();
|
|
||||||
if (userclass.charAt(0) == 'A')
|
if (userclass.charAt(0) == 'A')
|
||||||
onAOL=true;
|
onAOL = true;
|
||||||
if (userclass.charAt(1) == 'A')
|
if (userclass.charAt(1) == 'A') {
|
||||||
{
|
admin = true;
|
||||||
admin=true;
|
} else {
|
||||||
}
|
if (userclass.charAt(1) == 'U') {
|
||||||
else
|
unconfirmed = true;
|
||||||
{
|
} else {
|
||||||
if (userclass.charAt(1)=='U')
|
if (userclass.charAt(1) == 'O') {
|
||||||
{
|
confirmed = true;
|
||||||
unconfirmed=true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(userclass.charAt(1)=='O')
|
|
||||||
{
|
|
||||||
confirmed=true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (userclass.length()>2)
|
if (userclass.length() > 2) {
|
||||||
{
|
if (userclass.charAt(2) == 'U') {
|
||||||
if (userclass.charAt(2)=='U')
|
away = true;
|
||||||
{
|
}
|
||||||
away=true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the away status of the buddy specified by this update
|
/**
|
||||||
|
* Get the away status of the buddy specified by this update
|
||||||
|
*
|
||||||
* @return true if the buddy is "away"
|
* @return true if the buddy is "away"
|
||||||
*/
|
*/
|
||||||
public boolean isAway()
|
public boolean isAway() {
|
||||||
{
|
return (away);
|
||||||
return(away);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the response type of this response. This method is used by the response dispatcher within JaimConnection
|
/**
|
||||||
|
* Get the response type of this response. This method is used by the response dispatcher within JaimConnection
|
||||||
|
*
|
||||||
* @return The response type
|
* @return The response type
|
||||||
*/
|
*/
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return RESPONSE_TYPE;
|
return RESPONSE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the buddy name from this update
|
/**
|
||||||
|
* Obtain the buddy name from this update
|
||||||
|
*
|
||||||
* @return The buddy name
|
* @return The buddy name
|
||||||
*/
|
*/
|
||||||
public String getBuddy()
|
public String getBuddy() {
|
||||||
{
|
return (buddyName);
|
||||||
return(buddyName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the online status of this buddy update
|
/**
|
||||||
|
* Obtain the online status of this buddy update
|
||||||
|
*
|
||||||
* @return true if the buddy is on line
|
* @return true if the buddy is on line
|
||||||
*/
|
*/
|
||||||
public boolean isOnline()
|
public boolean isOnline() {
|
||||||
{
|
return (online);
|
||||||
return(online);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the idle time of this buddy
|
/**
|
||||||
|
* Obtain the idle time of this buddy
|
||||||
|
*
|
||||||
* @return The idle time in seconds
|
* @return The idle time in seconds
|
||||||
*/
|
*/
|
||||||
public int getIdleTime()
|
public int getIdleTime() {
|
||||||
{
|
return (idleTime);
|
||||||
return(idleTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the "Evil" (Warning) level of this buddy
|
/**
|
||||||
|
* Obtain the "Evil" (Warning) level of this buddy
|
||||||
|
*
|
||||||
* @return The warning level as a percentage
|
* @return The warning level as a percentage
|
||||||
*/
|
*/
|
||||||
public int getEvil()
|
public int getEvil() {
|
||||||
{
|
return (evil);
|
||||||
return(evil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Is this buddy an "Administrator"
|
/**
|
||||||
|
* Is this buddy an "Administrator"
|
||||||
|
*
|
||||||
* @return true if an administrator
|
* @return true if an administrator
|
||||||
*/
|
*/
|
||||||
public boolean isAdmin()
|
public boolean isAdmin() {
|
||||||
{
|
return (admin);
|
||||||
return(admin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** IS this buddy a "confirmed" user
|
/**
|
||||||
|
* IS this buddy a "confirmed" user
|
||||||
|
*
|
||||||
* @return True if this buddy is confirmed
|
* @return True if this buddy is confirmed
|
||||||
*/
|
*/
|
||||||
public boolean isConfirmed()
|
public boolean isConfirmed() {
|
||||||
{
|
return (confirmed);
|
||||||
return(confirmed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Is this user an "Unconfirmed user"
|
/**
|
||||||
|
* Is this user an "Unconfirmed user"
|
||||||
|
*
|
||||||
* @return True if this user is unconfirmed
|
* @return True if this user is unconfirmed
|
||||||
*/
|
*/
|
||||||
public boolean isUnconfirmed()
|
public boolean isUnconfirmed() {
|
||||||
{
|
return (unconfirmed);
|
||||||
return(unconfirmed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the signon time of this buddy
|
/**
|
||||||
|
* Get the signon time of this buddy
|
||||||
|
*
|
||||||
* @return The date/time of signon
|
* @return The date/time of signon
|
||||||
*/
|
*/
|
||||||
public Date getSignonTime()
|
public Date getSignonTime() {
|
||||||
{
|
return (signonTime);
|
||||||
return(signonTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return(Response.equalsIgnoreCase(RESPONSE_TYPE));
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -25,23 +25,25 @@
|
||||||
|
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
/** A BuddyUpdateTocResponse is delivered to a {@link JaimEventListener } when a buddy update is received from the TOC server
|
/**
|
||||||
|
* A BuddyUpdateTocResponse is delivered to a {@link JaimEventListener } when a buddy update is received from the TOC server
|
||||||
|
*
|
||||||
* @author paulw
|
* @author paulw
|
||||||
* @version $Revision: 1.7 $
|
* @version $Revision: 1.7 $
|
||||||
*/
|
*/
|
||||||
public class ChatInviteTocResponse extends TocResponse implements TocResponseHandler {
|
public class ChatInviteTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
public static String RESPONSE_TYPE = "CHAT_INVITE";
|
||||||
private String roomName;
|
private String roomName;
|
||||||
private String roomID;
|
private String roomID;
|
||||||
private String senderScreenname;
|
private String senderScreenname;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public static String RESPONSE_TYPE="CHAT_INVITE";
|
/**
|
||||||
|
* Creates new BuddyUpdateTocResponse
|
||||||
/** Creates new BuddyUpdateTocResponse */
|
*/
|
||||||
public ChatInviteTocResponse() {
|
public ChatInviteTocResponse() {
|
||||||
roomName = "";
|
roomName = "";
|
||||||
roomID = "";
|
roomID = "";
|
||||||
|
@ -49,20 +51,21 @@ public class ChatInviteTocResponse extends TocResponse implements TocResponseHan
|
||||||
message = "";
|
message = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The parseString method is used to populate the fields of this class from a Buddy Update string from the TOC server
|
/**
|
||||||
|
* The parseString method is used to populate the fields of this class from a Buddy Update string from the TOC server
|
||||||
|
*
|
||||||
* @param str The String containing the buddy update
|
* @param str The String containing the buddy update
|
||||||
*/
|
*/
|
||||||
public TocResponse parseString(String str) {
|
public TocResponse parseString(String str) {
|
||||||
ChatInviteTocResponse tr = new ChatInviteTocResponse();
|
ChatInviteTocResponse tr = new ChatInviteTocResponse();
|
||||||
tr.doParse(str);
|
tr.doParse(str);
|
||||||
return(tr);
|
return (tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
private void doParse(String str) {
|
||||||
{
|
cmd = str;
|
||||||
cmd=str;
|
StringTokenizer st = new StringTokenizer(str, ":");
|
||||||
StringTokenizer st=new StringTokenizer(str,":");
|
|
||||||
|
|
||||||
st.nextToken();
|
st.nextToken();
|
||||||
roomName = st.nextToken();
|
roomName = st.nextToken();
|
||||||
roomID = st.nextToken();
|
roomID = st.nextToken();
|
||||||
|
@ -70,9 +73,11 @@ public class ChatInviteTocResponse extends TocResponse implements TocResponseHan
|
||||||
message = st.nextToken();
|
message = st.nextToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the response type of this response. This method is used by the response dispatcher within JaimConnection
|
/**
|
||||||
|
* Get the response type of this response. This method is used by the response dispatcher within JaimConnection
|
||||||
|
*
|
||||||
* @return The response type
|
* @return The response type
|
||||||
*/
|
*/
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return RESPONSE_TYPE;
|
return RESPONSE_TYPE;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +85,7 @@ public class ChatInviteTocResponse extends TocResponse implements TocResponseHan
|
||||||
public String getRoomName() {
|
public String getRoomName() {
|
||||||
return roomName;
|
return roomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRoomID() {
|
public String getRoomID() {
|
||||||
return roomID;
|
return roomID;
|
||||||
}
|
}
|
||||||
|
@ -91,13 +97,15 @@ public class ChatInviteTocResponse extends TocResponse implements TocResponseHan
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return(Response.equalsIgnoreCase(RESPONSE_TYPE));
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -21,174 +21,189 @@
|
||||||
* ConfigTocResponse.java
|
* ConfigTocResponse.java
|
||||||
* Created on 1, October 2002
|
* Created on 1, October 2002
|
||||||
*/
|
*/
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/** A ConfigTocResponse contains the config message received from
|
|
||||||
* the toc server.
|
|
||||||
*This response is handled by the JaimConnection class, but may also be used by client programs.
|
|
||||||
*Once this event has been received, information returned from {@link JaimConnection#getGroups} is valid
|
|
||||||
* @author Brett Humphreys, Paul Wilkinson
|
|
||||||
*/
|
|
||||||
public class ConfigTocResponse extends TocResponse implements TocResponseHandler {
|
|
||||||
|
|
||||||
public static String RESPONSE_TYPE="CONFIG";
|
|
||||||
|
|
||||||
/** The Vector of Group objects */
|
|
||||||
private Vector buddyList = new Vector();
|
|
||||||
|
|
||||||
/** The HashMap of known buddies */
|
|
||||||
private HashMap buddies;
|
|
||||||
|
|
||||||
/** The mode for this configuration */
|
|
||||||
private int mode;
|
|
||||||
|
|
||||||
/** Value for mode that indicates PERMIT ALL mode */
|
|
||||||
public static final int PERMIT_ALL=1;
|
|
||||||
|
|
||||||
/** Value for mode that indicates DENY ALL mode */
|
|
||||||
public static final int DENY_ALL=2;
|
|
||||||
|
|
||||||
/** Value for mode that indicates PERMIT SOME mode */
|
|
||||||
public static final int PERMIT_SOME=3;
|
|
||||||
|
|
||||||
/** Value for mode that indicates DENY SOME mode */
|
|
||||||
public static final int DENY_SOME=4;
|
|
||||||
|
|
||||||
/** Returns an Enumeration of groups. Each Entry is a {@link Group}
|
|
||||||
* Each group then has an Enumeration of buddies within that group See {@link Group#enumerateBuddies}.
|
|
||||||
* @return list of Group elements or an empty list if none are found.
|
|
||||||
*/
|
|
||||||
public Enumeration enumerateGroups()
|
|
||||||
{
|
|
||||||
return buddyList.elements();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a Collection of groups. Each element is a {@link Group)
|
import java.util.*;
|
||||||
* @return the groups
|
|
||||||
*/
|
/**
|
||||||
|
* A ConfigTocResponse contains the config message received from
|
||||||
|
* the toc server.
|
||||||
|
* This response is handled by the JaimConnection class, but may also be used by client programs.
|
||||||
|
* Once this event has been received, information returned from {@link JaimConnection#getGroups} is valid
|
||||||
|
*
|
||||||
|
* @author Brett Humphreys, Paul Wilkinson
|
||||||
|
*/
|
||||||
|
public class ConfigTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value for mode that indicates PERMIT ALL mode
|
||||||
|
*/
|
||||||
|
public static final int PERMIT_ALL = 1;
|
||||||
|
/**
|
||||||
|
* Value for mode that indicates DENY ALL mode
|
||||||
|
*/
|
||||||
|
public static final int DENY_ALL = 2;
|
||||||
|
/**
|
||||||
|
* Value for mode that indicates PERMIT SOME mode
|
||||||
|
*/
|
||||||
|
public static final int PERMIT_SOME = 3;
|
||||||
|
/**
|
||||||
|
* Value for mode that indicates DENY SOME mode
|
||||||
|
*/
|
||||||
|
public static final int DENY_SOME = 4;
|
||||||
|
public static String RESPONSE_TYPE = "CONFIG";
|
||||||
|
/**
|
||||||
|
* The Vector of Group objects
|
||||||
|
*/
|
||||||
|
private final Vector buddyList = new Vector();
|
||||||
|
/**
|
||||||
|
* The HashMap of known buddies
|
||||||
|
*/
|
||||||
|
private HashMap buddies;
|
||||||
|
/**
|
||||||
|
* The mode for this configuration
|
||||||
|
*/
|
||||||
|
private int mode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an Enumeration of groups. Each Entry is a {@link Group}
|
||||||
|
* Each group then has an Enumeration of buddies within that group See {@link Group#enumerateBuddies}.
|
||||||
|
*
|
||||||
|
* @return list of Group elements or an empty list if none are found.
|
||||||
|
*/
|
||||||
|
public Enumeration enumerateGroups() {
|
||||||
|
return buddyList.elements();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a Collection of groups. Each element is a {@link Group)
|
||||||
|
*
|
||||||
|
* @return the groups
|
||||||
|
*/
|
||||||
public Collection getGroups() {
|
public Collection getGroups() {
|
||||||
java.util.Collection result = new Vector(buddyList);
|
java.util.Collection result = new Vector(buddyList);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Get the response type of this response. This method is used by the response dispatcher within JaimConnection
|
/**
|
||||||
* @return The response type
|
* Get the response type of this response. This method is used by the response dispatcher within JaimConnection
|
||||||
*/
|
*
|
||||||
public String getResponseType() {
|
* @return The response type
|
||||||
return RESPONSE_TYPE;
|
*/
|
||||||
}
|
public String getResponseType() {
|
||||||
/** Parses the config string.
|
return RESPONSE_TYPE;
|
||||||
*/
|
}
|
||||||
public TocResponse parseString(String message)
|
|
||||||
{
|
|
||||||
ConfigTocResponse tr = new ConfigTocResponse();
|
|
||||||
tr.doParse(message);
|
|
||||||
return(tr);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doParse(String message)
|
|
||||||
{
|
|
||||||
cmd=message;
|
|
||||||
int colonIndex = message.indexOf(':');
|
|
||||||
//throw away the first word.
|
|
||||||
message = message.substring(colonIndex+1, message.length());
|
|
||||||
buddies = new HashMap();
|
|
||||||
StringTokenizer tok = new StringTokenizer(message,"\n");
|
|
||||||
String itemType;
|
|
||||||
String itemValue;
|
|
||||||
Group currentGroup=null;
|
|
||||||
Buddy tmpBuddy;
|
|
||||||
while( tok.hasMoreTokens() )
|
|
||||||
{
|
|
||||||
// Can't tokenize on both \n and space since there could be spaces
|
|
||||||
// in the name, so parsing by hand.
|
|
||||||
itemType = tok.nextToken();
|
|
||||||
int firstSpace = itemType.indexOf(' ');
|
|
||||||
itemValue = itemType.substring(firstSpace+1, itemType.length());
|
|
||||||
itemType = itemType.substring(0, firstSpace);
|
|
||||||
|
|
||||||
char type = itemType.charAt(0);
|
/**
|
||||||
switch (type)
|
* Parses the config string.
|
||||||
{
|
*/
|
||||||
case 'g':
|
public TocResponse parseString(String message) {
|
||||||
currentGroup = new Group(itemValue);
|
ConfigTocResponse tr = new ConfigTocResponse();
|
||||||
buddyList.add(currentGroup);
|
tr.doParse(message);
|
||||||
break;
|
return (tr);
|
||||||
|
}
|
||||||
case 'b':
|
|
||||||
|
private void doParse(String message) {
|
||||||
tmpBuddy = getBuddy(itemValue);
|
cmd = message;
|
||||||
//this shouldn't happen, but:
|
int colonIndex = message.indexOf(':');
|
||||||
if(currentGroup==null)
|
//throw away the first word.
|
||||||
{
|
message = message.substring(colonIndex + 1);
|
||||||
currentGroup = new Group("<unknown>");
|
buddies = new HashMap();
|
||||||
buddyList.add(currentGroup);
|
StringTokenizer tok = new StringTokenizer(message, "\n");
|
||||||
}
|
String itemType;
|
||||||
currentGroup.addBuddy(tmpBuddy);
|
String itemValue;
|
||||||
|
Group currentGroup = null;
|
||||||
|
Buddy tmpBuddy;
|
||||||
break;
|
while (tok.hasMoreTokens()) {
|
||||||
|
// Can't tokenize on both \n and space since there could be spaces
|
||||||
case 'p':
|
// in the name, so parsing by hand.
|
||||||
tmpBuddy = getBuddy(itemValue);
|
itemType = tok.nextToken();
|
||||||
tmpBuddy.setPermit(true);
|
int firstSpace = itemType.indexOf(' ');
|
||||||
break;
|
itemValue = itemType.substring(firstSpace + 1);
|
||||||
|
itemType = itemType.substring(0, firstSpace);
|
||||||
case 'm':
|
|
||||||
setMode(Integer.valueOf(itemValue).intValue());
|
char type = itemType.charAt(0);
|
||||||
break;
|
switch (type) {
|
||||||
|
case 'g':
|
||||||
case 'd':
|
currentGroup = new Group(itemValue);
|
||||||
|
buddyList.add(currentGroup);
|
||||||
tmpBuddy = getBuddy(itemValue);
|
break;
|
||||||
tmpBuddy.setDeny(true);
|
|
||||||
break;
|
case 'b':
|
||||||
}
|
|
||||||
}
|
tmpBuddy = getBuddy(itemValue);
|
||||||
}
|
//this shouldn't happen, but:
|
||||||
|
if (currentGroup == null) {
|
||||||
/** Return an existing Buddy with the specified name or return a new buddy if the name is not known
|
currentGroup = new Group("<unknown>");
|
||||||
* The buddy is added to the buddies hash if it is a new buddy
|
buddyList.add(currentGroup);
|
||||||
* @param The name of the buddy we are looking for
|
}
|
||||||
* @return The buddy object
|
currentGroup.addBuddy(tmpBuddy);
|
||||||
*/
|
|
||||||
|
|
||||||
private Buddy getBuddy(String buddyName)
|
break;
|
||||||
{
|
|
||||||
Buddy retBuddy = (Buddy)buddies.get(buddyName);
|
case 'p':
|
||||||
if (retBuddy== null)
|
tmpBuddy = getBuddy(itemValue);
|
||||||
{
|
tmpBuddy.setPermit(true);
|
||||||
retBuddy=new Buddy(buddyName);
|
break;
|
||||||
buddies.put(buddyName,retBuddy);
|
|
||||||
|
case 'm':
|
||||||
|
setMode(Integer.valueOf(itemValue).intValue());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
|
||||||
|
tmpBuddy = getBuddy(itemValue);
|
||||||
|
tmpBuddy.setDeny(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return(retBuddy);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/** Sets the mode for this configuration
|
|
||||||
* @param modeVal the string value of the mode (1-4)
|
/**
|
||||||
*/
|
* Return an existing Buddy with the specified name or return a new buddy if the name is not known
|
||||||
public void setMode( int modeVal )
|
* The buddy is added to the buddies hash if it is a new buddy
|
||||||
{
|
*
|
||||||
mode = modeVal;
|
* @param The name of the buddy we are looking for
|
||||||
}
|
* @return The buddy object
|
||||||
|
*/
|
||||||
/** Gets the mode for this configuration
|
|
||||||
* @return mode for the configuration
|
private Buddy getBuddy(String buddyName) {
|
||||||
*/
|
Buddy retBuddy = (Buddy) buddies.get(buddyName);
|
||||||
public int getMode( )
|
if (retBuddy == null) {
|
||||||
{
|
retBuddy = new Buddy(buddyName);
|
||||||
return mode;
|
buddies.put(buddyName, retBuddy);
|
||||||
}
|
}
|
||||||
|
return (retBuddy);
|
||||||
/** Returns true if this response handler can handle the specified response.
|
}
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
|
||||||
* @return true if the response can be handled
|
/**
|
||||||
*/
|
* Gets the mode for this configuration
|
||||||
public boolean canHandle(String Response) {
|
*
|
||||||
return(Response.equalsIgnoreCase(RESPONSE_TYPE));
|
* @return mode for the configuration
|
||||||
}
|
*/
|
||||||
|
public int getMode() {
|
||||||
}
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the mode for this configuration
|
||||||
|
*
|
||||||
|
* @param modeVal the string value of the mode (1-4)
|
||||||
|
*/
|
||||||
|
public void setMode(int modeVal) {
|
||||||
|
mode = modeVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
|
* @return true if the response can be handled
|
||||||
|
*/
|
||||||
|
public boolean canHandle(String Response) {
|
||||||
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -27,24 +27,26 @@ package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a "pseudo" TOC response - it is delivered to JaimLib clients to indicate that the connection to the server has been lost.
|
* This is a "pseudo" TOC response - it is delivered to JaimLib clients to indicate that the connection to the server has been lost.
|
||||||
* @author wilko
|
*
|
||||||
|
* @author wilko
|
||||||
* @version: $revision: $
|
* @version: $revision: $
|
||||||
*/
|
*/
|
||||||
public class ConnectionLostTocResponse extends TocResponse {
|
public class ConnectionLostTocResponse extends TocResponse {
|
||||||
|
|
||||||
public static final String RESPONSE_TYPE="CONNECTIONLOST";
|
public static final String RESPONSE_TYPE = "CONNECTIONLOST";
|
||||||
|
|
||||||
/** Creates a new instance of LoginCompleteTocResponse */
|
/**
|
||||||
public ConnectionLostTocResponse() {
|
* Creates a new instance of LoginCompleteTocResponse
|
||||||
|
*/
|
||||||
|
public ConnectionLostTocResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return (RESPONSE_TYPE);
|
return (RESPONSE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return (RESPONSE_TYPE);
|
return (RESPONSE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -27,119 +27,118 @@ package com.wilko.jaim;
|
||||||
|
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
|
|
||||||
/** This TOC response is sent to a {@link JaimEventListener } when an error message is received from the TOC server
|
/**
|
||||||
|
* This TOC response is sent to a {@link JaimEventListener } when an error message is received from the TOC server
|
||||||
*
|
*
|
||||||
* @author paulw
|
* @author paulw
|
||||||
* @version $Revision: 1.7 $
|
* @version $Revision: 1.7 $
|
||||||
*/
|
*/
|
||||||
public class ErrorTocResponse extends TocResponse implements TocResponseHandler {
|
public class ErrorTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
public static final String RESPONSE_TYPE = "ERROR";
|
||||||
int errorCode;
|
int errorCode;
|
||||||
String errorText;
|
String errorText;
|
||||||
|
|
||||||
public static final String RESPONSE_TYPE="ERROR";
|
/**
|
||||||
|
* Creates new ErrorTocResponse
|
||||||
/** Creates new ErrorTocResponse */
|
*/
|
||||||
public ErrorTocResponse() {
|
public ErrorTocResponse() {
|
||||||
errorCode=0;
|
errorCode = 0;
|
||||||
errorText="";
|
errorText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Parse the error response string sent by the TOC server
|
* Obtain the error message that corresponds to the specified error code
|
||||||
|
*
|
||||||
|
* @param code The error code
|
||||||
|
* @return The error text
|
||||||
|
*/
|
||||||
|
static public String getErrorDescription(int code) {
|
||||||
|
try {
|
||||||
|
return (java.util.ResourceBundle.getBundle("com/wilko/jaim/TocErrorDescriptions").getString(Integer.toString(code)));
|
||||||
|
} catch (MissingResourceException e) {
|
||||||
|
return ("Unable to locate error description:" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the error response string sent by the TOC server
|
||||||
|
*
|
||||||
* @param str The error response string
|
* @param str The error response string
|
||||||
*/
|
*/
|
||||||
public TocResponse parseString(String str)
|
public TocResponse parseString(String str) {
|
||||||
{
|
ErrorTocResponse tr = new ErrorTocResponse();
|
||||||
ErrorTocResponse tr=new ErrorTocResponse();
|
|
||||||
tr.doParse(str);
|
tr.doParse(str);
|
||||||
return(tr);
|
return (tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
private void doParse(String str) {
|
||||||
{
|
|
||||||
|
cmd = str;
|
||||||
cmd=str;
|
int colonPos = str.indexOf(':');
|
||||||
int colonPos=str.indexOf(':');
|
if (colonPos != -1) {
|
||||||
if (colonPos!=-1)
|
str = str.substring(colonPos + 1);
|
||||||
{
|
colonPos = str.indexOf(':');
|
||||||
str=str.substring(colonPos+1);
|
if (colonPos != -1) {
|
||||||
colonPos=str.indexOf(':');
|
errorCode = Integer.parseInt(str.substring(0, colonPos));
|
||||||
if (colonPos!=-1)
|
errorText = str.substring(colonPos + 1);
|
||||||
{
|
} else {
|
||||||
errorCode=Integer.parseInt(str.substring(0,colonPos));
|
errorCode = Integer.parseInt(str);
|
||||||
errorText=str.substring(colonPos+1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorCode=Integer.parseInt(str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the error code for this response
|
/**
|
||||||
|
* Obtain the error code for this response
|
||||||
|
*
|
||||||
* @return The error code
|
* @return The error code
|
||||||
*/
|
*/
|
||||||
public int getErrorCode()
|
public int getErrorCode() {
|
||||||
{
|
return (errorCode);
|
||||||
return(errorCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the error text (if any) associated with this error response
|
/**
|
||||||
|
* Get the error text (if any) associated with this error response
|
||||||
|
*
|
||||||
* @return The error text
|
* @return The error text
|
||||||
*/
|
*/
|
||||||
public String getErrorText()
|
public String getErrorText() {
|
||||||
{
|
return (errorText);
|
||||||
return(errorText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Obtain the error message that corresponds to this error.
|
* Obtain the error message that corresponds to this error.
|
||||||
|
*
|
||||||
* @return The error text with any applicable error argument text inserted
|
* @return The error text with any applicable error argument text inserted
|
||||||
*/
|
*/
|
||||||
public String getErrorDescription() {
|
public String getErrorDescription() {
|
||||||
try {
|
try {
|
||||||
StringBuffer desc=new StringBuffer(java.util.ResourceBundle.getBundle("com/wilko/jaim/TocErrorDescriptions").getString(Integer.toString(errorCode)));
|
StringBuffer desc = new StringBuffer(java.util.ResourceBundle.getBundle("com/wilko/jaim/TocErrorDescriptions").getString(Integer.toString(errorCode)));
|
||||||
String sDesc=desc.toString();
|
String sDesc = desc.toString();
|
||||||
int argpos=sDesc.indexOf("%s");
|
int argpos = sDesc.indexOf("%s");
|
||||||
if (argpos != -1) {
|
if (argpos != -1) {
|
||||||
desc.replace(argpos,argpos+1,errorText);
|
desc.replace(argpos, argpos + 1, errorText);
|
||||||
}
|
}
|
||||||
return(desc.toString());
|
return (desc.toString());
|
||||||
|
|
||||||
}
|
} catch (MissingResourceException e) {
|
||||||
catch (MissingResourceException e) {
|
return ("Unable to locate error description:" + e);
|
||||||
return("Unable to locate error description:"+e.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the error message that corresponds to the specified error code
|
public String getResponseType() {
|
||||||
* @param code The error code
|
|
||||||
* @return The error text
|
|
||||||
*/
|
|
||||||
static public String getErrorDescription(int code)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return(java.util.ResourceBundle.getBundle("com/wilko/jaim/TocErrorDescriptions").getString(Integer.toString(code)));
|
|
||||||
}
|
|
||||||
catch (MissingResourceException e)
|
|
||||||
{
|
|
||||||
return("Unable to locate error description:"+e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getResponseType() {
|
|
||||||
return RESPONSE_TYPE;
|
return RESPONSE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return(Response.equalsIgnoreCase(RESPONSE_TYPE));
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -27,91 +27,99 @@ package com.wilko.jaim;
|
||||||
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
/** An EvilTocResponse is delivered to a {@link JaimEventListener } when the signed on buddy is "eviled" or warned
|
/**
|
||||||
|
* An EvilTocResponse is delivered to a {@link JaimEventListener } when the signed on buddy is "eviled" or warned
|
||||||
|
*
|
||||||
* @author paulw
|
* @author paulw
|
||||||
* @version $Revision: 1.6 $
|
* @version $Revision: 1.6 $
|
||||||
*/
|
*/
|
||||||
public class EvilTocResponse extends TocResponse implements TocResponseHandler {
|
public class EvilTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
public static final String RESPONSE_TYPE = "EVILED";
|
||||||
private boolean anonymousEvil;
|
private boolean anonymousEvil;
|
||||||
private int evilAmount;
|
private int evilAmount;
|
||||||
private String evilBy;
|
private String evilBy;
|
||||||
|
|
||||||
public static final String RESPONSE_TYPE="EVILED";
|
/**
|
||||||
|
* Creates new EvilTocResponse
|
||||||
/** Creates new EvilTocResponse */
|
*/
|
||||||
public EvilTocResponse() {
|
public EvilTocResponse() {
|
||||||
anonymousEvil=true;
|
anonymousEvil = true;
|
||||||
evilBy="";
|
evilBy = "";
|
||||||
evilAmount=0;
|
evilAmount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse the evil message from the TOC server
|
/**
|
||||||
|
* Parse the evil message from the TOC server
|
||||||
|
*
|
||||||
* @param str The evil message
|
* @param str The evil message
|
||||||
*/
|
*/
|
||||||
public TocResponse parseString(java.lang.String str) {
|
public TocResponse parseString(java.lang.String str) {
|
||||||
EvilTocResponse tr=new EvilTocResponse();
|
EvilTocResponse tr = new EvilTocResponse();
|
||||||
tr.doParse(str);
|
tr.doParse(str);
|
||||||
return(tr);
|
return (tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
private void doParse(String str) {
|
||||||
{
|
|
||||||
|
StringTokenizer st = new StringTokenizer(str, ":");
|
||||||
StringTokenizer st=new StringTokenizer(str,":");
|
|
||||||
|
|
||||||
st.nextToken(); // skip over "EVILED"
|
st.nextToken(); // skip over "EVILED"
|
||||||
evilAmount=Integer.parseInt(st.nextToken());
|
evilAmount = Integer.parseInt(st.nextToken());
|
||||||
if (st.hasMoreTokens())
|
if (st.hasMoreTokens()) {
|
||||||
{
|
evilBy = st.nextToken();
|
||||||
evilBy=st.nextToken();
|
anonymousEvil = false;
|
||||||
anonymousEvil=false;
|
} else {
|
||||||
}
|
anonymousEvil = true;
|
||||||
else
|
|
||||||
{
|
|
||||||
anonymousEvil=true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the evil amount from this response. This is the current evil or warning level for the authenticated buddy, not the increment specified by the last warning
|
/**
|
||||||
|
* Get the evil amount from this response. This is the current evil or warning level for the authenticated buddy, not the increment specified by the last warning
|
||||||
|
*
|
||||||
* @return The cumulative evil or warning level
|
* @return The cumulative evil or warning level
|
||||||
*/
|
*/
|
||||||
public int getEvilAmount()
|
public int getEvilAmount() {
|
||||||
{
|
return (evilAmount);
|
||||||
return(evilAmount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the name of the buddy that issued the warning.
|
/**
|
||||||
|
* Obtain the name of the buddy that issued the warning.
|
||||||
|
*
|
||||||
* @return The buddy name that issued the warning
|
* @return The buddy name that issued the warning
|
||||||
* @see #isAnonymous
|
* @see #isAnonymous
|
||||||
*/
|
*/
|
||||||
public String getEvilBy()
|
public String getEvilBy() {
|
||||||
{
|
return (evilBy);
|
||||||
return(evilBy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the anonymous status of this warning
|
/**
|
||||||
|
* Obtain the anonymous status of this warning
|
||||||
|
*
|
||||||
* @return true if this warning was issued anonymously
|
* @return true if this warning was issued anonymously
|
||||||
*/
|
*/
|
||||||
public boolean isAnonymous()
|
public boolean isAnonymous() {
|
||||||
{
|
return (anonymousEvil);
|
||||||
return(anonymousEvil);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used by the response dispatcher
|
/**
|
||||||
|
* Used by the response dispatcher
|
||||||
|
*
|
||||||
* @return The response type
|
* @return The response type
|
||||||
*/
|
*/
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return RESPONSE_TYPE;
|
return RESPONSE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return(Response.equalsIgnoreCase(RESPONSE_TYPE));
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,51 +26,48 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class FLAPDataFrame extends FLAPFrame {
|
public class FLAPDataFrame extends FLAPFrame {
|
||||||
|
|
||||||
private int frameLen;
|
private int frameLen;
|
||||||
|
|
||||||
/** Creates new FlapDataFrame */
|
/**
|
||||||
|
* Creates new FlapDataFrame
|
||||||
|
*/
|
||||||
public FLAPDataFrame() {
|
public FLAPDataFrame() {
|
||||||
frame[1]=FLAP_FRAME_DATA;
|
frame[1] = FLAP_FRAME_DATA;
|
||||||
frameLen=1;
|
frameLen = 1;
|
||||||
frame[FLAP_DATA_OFFSET]=0;
|
frame[FLAP_DATA_OFFSET] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLAPDataFrame(byte frameData[])
|
public FLAPDataFrame(byte[] frameData) {
|
||||||
{
|
frame[1] = FLAP_FRAME_DATA;
|
||||||
frame[1]=FLAP_FRAME_DATA;
|
frameLen = 1;
|
||||||
frameLen=1;
|
frame[FLAP_DATA_OFFSET] = 0;
|
||||||
frame[FLAP_DATA_OFFSET]=0;
|
|
||||||
setFrameData(frameData);
|
setFrameData(frameData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getFLAPFrameType() {
|
public int getFLAPFrameType() {
|
||||||
return(FLAPFrame.FLAP_FRAME_DATA);
|
return (FLAPFrame.FLAP_FRAME_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addString(String s)
|
public void addString(String s) {
|
||||||
{
|
|
||||||
frameLen--; // Backspace over '0'
|
frameLen--; // Backspace over '0'
|
||||||
for (int i=0;i<s.length();i++)
|
for (int i = 0; i < s.length(); i++) {
|
||||||
{
|
frame[FLAP_DATA_OFFSET + frameLen++] = (byte) s.charAt(i);
|
||||||
frame[FLAP_DATA_OFFSET+frameLen++]=(byte)s.charAt(i);
|
|
||||||
}
|
}
|
||||||
frame[FLAP_DATA_OFFSET+frameLen++]=0;
|
frame[FLAP_DATA_OFFSET + frameLen++] = 0;
|
||||||
setLength(frameLen);
|
setLength(frameLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getContent()
|
public byte[] getContent() {
|
||||||
{
|
|
||||||
byte[] retarray = new byte[getLength()];
|
byte[] retarray = new byte[getLength()];
|
||||||
|
|
||||||
System.arraycopy(frame,FLAPFrame.FLAP_DATA_OFFSET,retarray,0,getLength());
|
System.arraycopy(frame, FLAPFrame.FLAP_DATA_OFFSET, retarray, 0, getLength());
|
||||||
return(retarray);
|
return (retarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -25,27 +25,27 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class FLAPErrorFrame extends FLAPFrame {
|
public class FLAPErrorFrame extends FLAPFrame {
|
||||||
|
|
||||||
/** Creates new FLAPErrorFrame */
|
/**
|
||||||
|
* Creates new FLAPErrorFrame
|
||||||
|
*/
|
||||||
public FLAPErrorFrame() {
|
public FLAPErrorFrame() {
|
||||||
frame[1]=FLAP_FRAME_ERROR;
|
frame[1] = FLAP_FRAME_ERROR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLAPErrorFrame(byte frameData[])
|
public FLAPErrorFrame(byte[] frameData) {
|
||||||
{
|
frame[1] = FLAP_FRAME_ERROR;
|
||||||
frame[1]=FLAP_FRAME_ERROR;
|
|
||||||
setFrameData(frameData);
|
setFrameData(frameData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getFLAPFrameType() {
|
public int getFLAPFrameType() {
|
||||||
return FLAPFrame.FLAP_FRAME_ERROR;
|
return FLAPFrame.FLAP_FRAME_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,94 +26,84 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
public abstract class FLAPFrame {
|
public abstract class FLAPFrame {
|
||||||
|
|
||||||
public static final int FLAP_FRAME_SIGNON=1;
|
public static final int FLAP_FRAME_SIGNON = 1;
|
||||||
public static final int FLAP_FRAME_DATA=2;
|
public static final int FLAP_FRAME_DATA = 2;
|
||||||
public static final int FLAP_FRAME_ERROR=3;
|
public static final int FLAP_FRAME_ERROR = 3;
|
||||||
public static final int FLAP_FRAME_SIGNOFF=4;
|
public static final int FLAP_FRAME_SIGNOFF = 4;
|
||||||
public static final int FLAP_FRAME_KEEP_ALIVE=5;
|
public static final int FLAP_FRAME_KEEP_ALIVE = 5;
|
||||||
public static final int FLAP_DATA_OFFSET=6;
|
public static final int FLAP_DATA_OFFSET = 6;
|
||||||
|
|
||||||
protected byte[] frame;
|
protected byte[] frame;
|
||||||
protected int fLen;
|
protected int fLen;
|
||||||
|
|
||||||
/** Creates new FLAPFrame */
|
/**
|
||||||
|
* Creates new FLAPFrame
|
||||||
|
*/
|
||||||
public FLAPFrame() {
|
public FLAPFrame() {
|
||||||
initialise();
|
initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setFrameData(byte b[])
|
protected void initialise() {
|
||||||
{
|
|
||||||
frame=new byte[b.length];
|
|
||||||
fLen=b.length;
|
|
||||||
System.arraycopy(b,0,frame,0,b.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initialise()
|
|
||||||
{
|
|
||||||
frame = new byte[8192];
|
frame = new byte[8192];
|
||||||
frame[0]=(byte)'*';
|
frame[0] = (byte) '*';
|
||||||
frame[1]=0;
|
frame[1] = 0;
|
||||||
frame[2]=0;
|
frame[2] = 0;
|
||||||
frame[3]=0;
|
frame[3] = 0;
|
||||||
frame[4]=0;
|
frame[4] = 0;
|
||||||
frame[5]=0;
|
frame[5] = 0;
|
||||||
fLen=6;
|
fLen = 6;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSequence(int sequence)
|
public int getSequence() {
|
||||||
{
|
return ((frame[2] & 0xff) * 256 + (frame[3] & 0xff));
|
||||||
frame[2]=(byte)((sequence/256)&0xff);
|
}
|
||||||
frame[3]=(byte)(sequence&0xff);
|
|
||||||
}
|
public void setSequence(int sequence) {
|
||||||
|
frame[2] = (byte) ((sequence / 256) & 0xff);
|
||||||
public int getSequence()
|
frame[3] = (byte) (sequence & 0xff);
|
||||||
{
|
}
|
||||||
return((frame[2]&0xff)*256+(frame[3]&0xff));
|
|
||||||
}
|
public int getLength() {
|
||||||
|
return ((frame[4] & 0xff) * 256 + (frame[5] & 0xff));
|
||||||
public int getLength()
|
}
|
||||||
{
|
|
||||||
return((frame[4]&0xff)*256+(frame[5]&0xff));
|
public void setLength(int length) {
|
||||||
}
|
frame[4] = (byte) (length / 256);
|
||||||
|
frame[5] = (byte) (length & 0xff);
|
||||||
public void setLength(int length)
|
fLen = length + FLAP_DATA_OFFSET;
|
||||||
{
|
}
|
||||||
frame[4]=(byte)(length/256);
|
|
||||||
frame[5]=(byte)(length&0xff);
|
public byte[] getFrameData() {
|
||||||
fLen=length+FLAP_DATA_OFFSET;
|
byte[] b = new byte[fLen];
|
||||||
}
|
System.arraycopy(frame, 0, b, 0, fLen);
|
||||||
|
return (b);
|
||||||
public byte[] getFrameData()
|
}
|
||||||
{
|
|
||||||
byte[] b=new byte[fLen];
|
protected void setFrameData(byte[] b) {
|
||||||
System.arraycopy(frame,0,b,0,fLen);
|
frame = new byte[b.length];
|
||||||
return(b);
|
fLen = b.length;
|
||||||
|
System.arraycopy(b, 0, frame, 0, b.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer temp = new StringBuffer();
|
||||||
|
for (int i = 0; i < fLen; i++) {
|
||||||
|
int k = frame[i] & 0xff;
|
||||||
|
if (k < 16) {
|
||||||
|
temp.append("0" + Integer.toHexString(k) + " ");
|
||||||
|
} else {
|
||||||
|
temp.append(Integer.toHexString(k) + " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (temp.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuffer temp=new StringBuffer();
|
|
||||||
for (int i=0;i<fLen;i++)
|
|
||||||
{
|
|
||||||
int k=frame[i]&0xff;
|
|
||||||
if (k<16)
|
|
||||||
{
|
|
||||||
temp.append("0"+Integer.toHexString(k)+" ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
temp.append(Integer.toHexString(k)+" ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(temp.toString());
|
|
||||||
}
|
|
||||||
public abstract int getFLAPFrameType();
|
public abstract int getFLAPFrameType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,8 +26,7 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class FLAPFrameException extends java.lang.Exception {
|
public class FLAPFrameException extends java.lang.Exception {
|
||||||
|
@ -41,6 +40,7 @@ public class FLAPFrameException extends java.lang.Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an <code>FLAPFrameException</code> with the specified detail message.
|
* Constructs an <code>FLAPFrameException</code> with the specified detail message.
|
||||||
|
*
|
||||||
* @param msg the detail message.
|
* @param msg the detail message.
|
||||||
*/
|
*/
|
||||||
public FLAPFrameException(String msg) {
|
public FLAPFrameException(String msg) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,44 +26,43 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public abstract class FLAPFrameFactory {
|
public abstract class FLAPFrameFactory {
|
||||||
|
|
||||||
/** Creates new FLAPFrameFactory */
|
/**
|
||||||
|
* Creates new FLAPFrameFactory
|
||||||
|
*/
|
||||||
public FLAPFrameFactory() {
|
public FLAPFrameFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FLAPFrame createFLAPFrame(byte[] frameData) throws FLAPFrameException {
|
public static FLAPFrame createFLAPFrame(byte[] frameData) throws FLAPFrameException {
|
||||||
FLAPFrame f=null;
|
FLAPFrame f = null;
|
||||||
if (frameData[0]!='*')
|
if (frameData[0] != '*') {
|
||||||
{
|
|
||||||
throw new FLAPFrameException("Frame does not start with '*'");
|
throw new FLAPFrameException("Frame does not start with '*'");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (frameData[1])
|
switch (frameData[1]) {
|
||||||
{
|
|
||||||
case FLAPFrame.FLAP_FRAME_SIGNON:
|
case FLAPFrame.FLAP_FRAME_SIGNON:
|
||||||
f=new FLAPSignonFrame(frameData);
|
f = new FLAPSignonFrame(frameData);
|
||||||
break;
|
break;
|
||||||
case FLAPFrame.FLAP_FRAME_DATA:
|
case FLAPFrame.FLAP_FRAME_DATA:
|
||||||
f=new FLAPDataFrame(frameData);
|
f = new FLAPDataFrame(frameData);
|
||||||
break;
|
break;
|
||||||
case FLAPFrame.FLAP_FRAME_ERROR:
|
case FLAPFrame.FLAP_FRAME_ERROR:
|
||||||
f=new FLAPErrorFrame(frameData);
|
f = new FLAPErrorFrame(frameData);
|
||||||
break;
|
break;
|
||||||
case FLAPFrame.FLAP_FRAME_SIGNOFF:
|
case FLAPFrame.FLAP_FRAME_SIGNOFF:
|
||||||
f=new FLAPSignoffFrame(frameData);
|
f = new FLAPSignoffFrame(frameData);
|
||||||
break;
|
break;
|
||||||
case FLAPFrame.FLAP_FRAME_KEEP_ALIVE:
|
case FLAPFrame.FLAP_FRAME_KEEP_ALIVE:
|
||||||
f=new FLAPKeepAliveFrame(frameData);
|
f = new FLAPKeepAliveFrame(frameData);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new FLAPFrameException("Illegal FLAP Frame type: "+Integer.toString(frameData[1]));
|
throw new FLAPFrameException("Illegal FLAP Frame type: " + Integer.toString(frameData[1]));
|
||||||
}
|
}
|
||||||
return(f);
|
return (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,51 +26,44 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class FLAPInputFrame extends FLAPFrame {
|
public class FLAPInputFrame extends FLAPFrame {
|
||||||
|
|
||||||
/** Creates new FLAPInputFrame */
|
/**
|
||||||
private int frameLen;
|
* Creates new FLAPInputFrame
|
||||||
|
*/
|
||||||
|
private int frameLen;
|
||||||
|
|
||||||
public FLAPInputFrame() {
|
public FLAPInputFrame() {
|
||||||
frameLen=0;
|
frameLen = 0;
|
||||||
super.initialise();
|
super.initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFrameData(byte b)
|
public void addFrameData(byte b) {
|
||||||
{
|
frame[frameLen++] = b;
|
||||||
frame[frameLen++]=b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getFrameData()
|
public byte[] getFrameData() {
|
||||||
{
|
byte[] b = new byte[frameLen];
|
||||||
byte[] b=new byte[frameLen];
|
System.arraycopy(frame, 0, b, 0, frameLen);
|
||||||
System.arraycopy(frame,0,b,0,frameLen);
|
return (b);
|
||||||
return(b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetInputFrame()
|
public void resetInputFrame() {
|
||||||
{
|
frameLen = 0;
|
||||||
frameLen=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean completeFrameRead()
|
public boolean completeFrameRead() {
|
||||||
{
|
if (frameLen > 5) {
|
||||||
if (frameLen > 5)
|
return frameLen - 6 == getLength();
|
||||||
{
|
|
||||||
if (frameLen-6 == getLength())
|
|
||||||
{
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return(false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFLAPFrameType() {
|
public int getFLAPFrameType() {
|
||||||
return(-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,31 +26,30 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
public class FLAPKeepAliveFrame extends FLAPFrame {
|
public class FLAPKeepAliveFrame extends FLAPFrame {
|
||||||
|
|
||||||
/** Creates new FLAPKeepAliveFrame */
|
/**
|
||||||
|
* Creates new FLAPKeepAliveFrame
|
||||||
|
*/
|
||||||
public FLAPKeepAliveFrame() {
|
public FLAPKeepAliveFrame() {
|
||||||
this.initialise();
|
this.initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLAPKeepAliveFrame(byte frameData[])
|
public FLAPKeepAliveFrame(byte[] frameData) {
|
||||||
{
|
|
||||||
initialise();
|
initialise();
|
||||||
setFrameData(frameData);
|
setFrameData(frameData);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initialise()
|
protected void initialise() {
|
||||||
{
|
|
||||||
super.initialise();
|
super.initialise();
|
||||||
frame[1]=FLAP_FRAME_KEEP_ALIVE;
|
frame[1] = FLAP_FRAME_KEEP_ALIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFLAPFrameType() {
|
public int getFLAPFrameType() {
|
||||||
return (FLAPFrame.FLAP_FRAME_KEEP_ALIVE);
|
return (FLAPFrame.FLAP_FRAME_KEEP_ALIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,27 +26,27 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class FLAPSignoffFrame extends FLAPFrame {
|
public class FLAPSignoffFrame extends FLAPFrame {
|
||||||
|
|
||||||
/** Creates new FlapSignonFrame */
|
/**
|
||||||
|
* Creates new FlapSignonFrame
|
||||||
|
*/
|
||||||
public FLAPSignoffFrame() {
|
public FLAPSignoffFrame() {
|
||||||
|
|
||||||
frame[1]=FLAP_FRAME_SIGNOFF;
|
frame[1] = FLAP_FRAME_SIGNOFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLAPSignoffFrame(byte frameData[])
|
public FLAPSignoffFrame(byte[] frameData) {
|
||||||
{
|
frame[1] = FLAP_FRAME_SIGNOFF;
|
||||||
frame[1]=FLAP_FRAME_SIGNOFF;
|
|
||||||
setFrameData(frameData);
|
setFrameData(frameData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getFLAPFrameType() {
|
public int getFLAPFrameType() {
|
||||||
return(FLAPFrame.FLAP_FRAME_SIGNOFF);
|
return (FLAPFrame.FLAP_FRAME_SIGNOFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,65 +26,57 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class FLAPSignonFrame extends FLAPFrame {
|
public class FLAPSignonFrame extends FLAPFrame {
|
||||||
|
|
||||||
/** Creates new FlapSignonFrame */
|
/**
|
||||||
|
* Creates new FlapSignonFrame
|
||||||
|
*/
|
||||||
public FLAPSignonFrame() {
|
public FLAPSignonFrame() {
|
||||||
frame[1]=FLAP_FRAME_SIGNON;
|
frame[1] = FLAP_FRAME_SIGNON;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FLAPSignonFrame(byte frameData[])
|
public FLAPSignonFrame(byte[] frameData) {
|
||||||
{
|
frame[1] = FLAP_FRAME_SIGNON;
|
||||||
frame[1]=FLAP_FRAME_SIGNON;
|
|
||||||
setFrameData(frameData);
|
setFrameData(frameData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFLAPVersion()
|
public int getFLAPVersion() {
|
||||||
{
|
return (((frame[6] & 0xff) * 16777216) + ((frame[7] & 0xff) * 65536) + ((frame[8] & 0xff) * 256) + (frame[9] & 0xff));
|
||||||
return(((frame[6]&0xff)*16777216)+((frame[7]&0xff)*65536)+((frame[8]&0xff)*256)+(frame[9]&0xff));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFLAPVersion(int version)
|
public void setFLAPVersion(int version) {
|
||||||
{
|
for (int i = 3; i >= 0; i--) {
|
||||||
for (int i=3;i>=0;i--)
|
frame[6 + i] = (byte) (version & 0xff);
|
||||||
{
|
version = version >> 8;
|
||||||
frame[6+i]=(byte)(version&0xff);
|
|
||||||
version=version>>8;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTLVTag(int tag)
|
public void setTLVTag(int tag) {
|
||||||
{
|
for (int i = 1; i >= 0; i--) {
|
||||||
for (int i=1;i>=0;i--)
|
frame[10 + i] = (byte) (tag & 0xff);
|
||||||
{
|
tag = tag >> 8;
|
||||||
frame[10+i]=(byte)(tag&0xff);
|
|
||||||
tag=tag>>8;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserName(String name)
|
public void setUserName(String name) {
|
||||||
{
|
|
||||||
|
int len = 0;
|
||||||
int len=0;
|
for (int i = 0; i < name.length(); i++) {
|
||||||
for (int i=0;i<name.length();i++)
|
char c = name.charAt(i);
|
||||||
{
|
if (c != ' ') {
|
||||||
char c = name.charAt(i);
|
frame[FLAP_DATA_OFFSET + 8 + len++] = (byte) c;
|
||||||
if (c != ' ')
|
}
|
||||||
{
|
|
||||||
frame[FLAP_DATA_OFFSET+8+len++]=(byte)c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setLength(8+len);
|
setLength(8 + len);
|
||||||
frame[FLAP_DATA_OFFSET+6]=(byte)(len/256);
|
frame[FLAP_DATA_OFFSET + 6] = (byte) (len / 256);
|
||||||
frame[FLAP_DATA_OFFSET+7]=(byte)(len&0xff);
|
frame[FLAP_DATA_OFFSET + 7] = (byte) (len & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFLAPFrameType() {
|
public int getFLAPFrameType() {
|
||||||
return(FLAPFrame.FLAP_FRAME_SIGNON);
|
return (FLAPFrame.FLAP_FRAME_SIGNON);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -25,61 +25,71 @@
|
||||||
|
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/** A GenericTocResponse is used internally in the Response parsing and processing logic of {@link JaimConnection}
|
/**
|
||||||
|
* A GenericTocResponse is used internally in the Response parsing and processing logic of {@link JaimConnection}
|
||||||
|
*
|
||||||
* @author paulw
|
* @author paulw
|
||||||
* @version $Revision: 1.5 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
public class GenericTocResponse extends TocResponse implements TocResponseHandler {
|
public class GenericTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
/** Creates new GenericTocCommand */
|
/**
|
||||||
|
* Creates new GenericTocCommand
|
||||||
|
*/
|
||||||
public GenericTocResponse() {
|
public GenericTocResponse() {
|
||||||
this.cmd="";
|
this.cmd = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse an incoming string
|
/**
|
||||||
|
* Parse an incoming string
|
||||||
|
*
|
||||||
* @param str The response string to be parsed
|
* @param str The response string to be parsed
|
||||||
*/
|
*/
|
||||||
public TocResponse parseString(String str)
|
public TocResponse parseString(String str) {
|
||||||
{
|
GenericTocResponse tr = new GenericTocResponse();
|
||||||
GenericTocResponse tr=new GenericTocResponse();
|
|
||||||
tr.doParse(str);
|
tr.doParse(str);
|
||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
private void doParse(String str) {
|
||||||
{
|
cmd = str;
|
||||||
cmd=str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a byte array that contains the response
|
/**
|
||||||
|
* Get a byte array that contains the response
|
||||||
|
*
|
||||||
* @return The response as an array of bytes
|
* @return The response as an array of bytes
|
||||||
*/
|
*/
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(cmd.getBytes());
|
return (cmd.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert this response to a string
|
/**
|
||||||
|
* Convert this response to a string
|
||||||
|
*
|
||||||
* @return The response as a string
|
* @return The response as a string
|
||||||
*/
|
*/
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return (cmd);
|
||||||
return(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used in the response dispatching process
|
/**
|
||||||
|
* Used in the response dispatching process
|
||||||
|
*
|
||||||
* @return The respnse type
|
* @return The respnse type
|
||||||
*/
|
*/
|
||||||
public String getResponseType()
|
public String getResponseType() {
|
||||||
{
|
return ("UNKNOWN");
|
||||||
return("UNKNOWN");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return(true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -25,82 +25,89 @@
|
||||||
|
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/** This response is delivered to a {@link JaimEventListener } when a GOTO response is received from TOC
|
/**
|
||||||
|
* This response is delivered to a {@link JaimEventListener } when a GOTO response is received from TOC
|
||||||
|
*
|
||||||
* @author paulw
|
* @author paulw
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class GotoTocResponse extends TocResponse implements TocResponseHandler {
|
public class GotoTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
public static final String RESPONSE_TYPE = "GOTO_URL";
|
||||||
String windowName;
|
String windowName;
|
||||||
boolean autoResponse;
|
boolean autoResponse;
|
||||||
String URL;
|
String URL;
|
||||||
|
|
||||||
public static final String RESPONSE_TYPE="GOTO_URL";
|
|
||||||
|
|
||||||
/** Creates new GotoTocResponse */
|
|
||||||
public GotoTocResponse() {
|
|
||||||
windowName="";
|
|
||||||
URL="";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Obtain the suggested window name for this URL
|
|
||||||
* @return The window name
|
|
||||||
*/
|
|
||||||
public String getWindowName()
|
|
||||||
{
|
|
||||||
return(windowName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Obtain the URL
|
|
||||||
* @return The URL
|
|
||||||
*/
|
|
||||||
public String getURL()
|
|
||||||
{
|
|
||||||
return(URL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Parse an incoming response string
|
/**
|
||||||
* @param str The string to be parsed
|
* Creates new GotoTocResponse
|
||||||
*/
|
*/
|
||||||
public TocResponse parseString(java.lang.String str) {
|
public GotoTocResponse() {
|
||||||
GotoTocResponse tr=new GotoTocResponse();
|
windowName = "";
|
||||||
tr.doParse(str);
|
URL = "";
|
||||||
return(tr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
/**
|
||||||
{
|
* Obtain the suggested window name for this URL
|
||||||
cmd=str;
|
*
|
||||||
int colonPos=str.indexOf(':');
|
* @return The window name
|
||||||
if (colonPos!=-1)
|
*/
|
||||||
{
|
public String getWindowName() {
|
||||||
str=str.substring(colonPos+1);
|
return (windowName);
|
||||||
colonPos=str.indexOf(':');
|
}
|
||||||
if (colonPos != -1)
|
|
||||||
{
|
/**
|
||||||
windowName=str.substring(0,colonPos);
|
* Obtain the URL
|
||||||
URL=str.substring(colonPos+1);
|
*
|
||||||
|
* @return The URL
|
||||||
|
*/
|
||||||
|
public String getURL() {
|
||||||
|
return (URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse an incoming response string
|
||||||
|
*
|
||||||
|
* @param str The string to be parsed
|
||||||
|
*/
|
||||||
|
public TocResponse parseString(java.lang.String str) {
|
||||||
|
GotoTocResponse tr = new GotoTocResponse();
|
||||||
|
tr.doParse(str);
|
||||||
|
return (tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doParse(String str) {
|
||||||
|
cmd = str;
|
||||||
|
int colonPos = str.indexOf(':');
|
||||||
|
if (colonPos != -1) {
|
||||||
|
str = str.substring(colonPos + 1);
|
||||||
|
colonPos = str.indexOf(':');
|
||||||
|
if (colonPos != -1) {
|
||||||
|
windowName = str.substring(0, colonPos);
|
||||||
|
URL = str.substring(colonPos + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the response type for response dispatching purposes
|
/**
|
||||||
|
* Obtain the response type for response dispatching purposes
|
||||||
|
*
|
||||||
* @return The response type
|
* @return The response type
|
||||||
*/
|
*/
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return(RESPONSE_TYPE);
|
return (RESPONSE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,72 +25,90 @@
|
||||||
|
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
/** This is a logical user group. It holds a set of users.
|
/**
|
||||||
|
* This is a logical user group. It holds a set of users.
|
||||||
|
*
|
||||||
* @author Brett Humphreys
|
* @author Brett Humphreys
|
||||||
*/
|
*/
|
||||||
public class Group {
|
public class Group {
|
||||||
|
|
||||||
/** Vector of buddies for this group */
|
/**
|
||||||
private Vector buddies = new Vector();
|
* Vector of buddies for this group
|
||||||
|
*/
|
||||||
/** Name of this group */
|
private final Vector buddies = new Vector();
|
||||||
private String groupName;
|
|
||||||
|
/**
|
||||||
/** This constructor sets the name of the group
|
* Name of this group
|
||||||
|
*/
|
||||||
|
private final String groupName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor sets the name of the group
|
||||||
|
*
|
||||||
* @param name the group name
|
* @param name the group name
|
||||||
*/
|
*/
|
||||||
public Group( String name ) {
|
public Group(String name) {
|
||||||
groupName = name;
|
groupName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method adds a buddy to the end of the group
|
/**
|
||||||
|
* This method adds a buddy to the end of the group
|
||||||
|
*
|
||||||
* @param buddy The buddy object to associate with this group
|
* @param buddy The buddy object to associate with this group
|
||||||
*/
|
*/
|
||||||
public void addBuddy(Buddy buddy) {
|
public void addBuddy(Buddy buddy) {
|
||||||
buddies.add(buddy);
|
buddies.add(buddy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method adds a buddy to the specified location in the group
|
/**
|
||||||
* If the specified location is beyond the end of the group, then the buddy is added to the end of the group
|
* This method adds a buddy to the specified location in the group
|
||||||
|
* If the specified location is beyond the end of the group, then the buddy is added to the end of the group
|
||||||
|
*
|
||||||
* @param buddy The buddy object to associate with this group
|
* @param buddy The buddy object to associate with this group
|
||||||
* @param pos the position to add the buddy
|
* @param pos the position to add the buddy
|
||||||
*/
|
*/
|
||||||
public void addBuddy(Buddy buddy,int pos) {
|
public void addBuddy(Buddy buddy, int pos) {
|
||||||
if (pos > buddies.size()) {
|
if (pos > buddies.size()) {
|
||||||
buddies.add(buddy);
|
buddies.add(buddy);
|
||||||
}
|
} else {
|
||||||
else {
|
buddies.add(pos, buddy);
|
||||||
buddies.add(pos,buddy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method gets the group name
|
/**
|
||||||
|
* This method gets the group name
|
||||||
|
*
|
||||||
* @return the group name
|
* @return the group name
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return groupName;
|
return groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method returns the buddies in this group
|
/**
|
||||||
|
* This method returns the buddies in this group
|
||||||
|
*
|
||||||
* @return an Enumeration of {@link Buddy} objects
|
* @return an Enumeration of {@link Buddy} objects
|
||||||
*/
|
*/
|
||||||
public Enumeration enumerateBuddies() {
|
public Enumeration enumerateBuddies() {
|
||||||
return buddies.elements();
|
return buddies.elements();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method returns the number of buddies in this group
|
/**
|
||||||
|
* This method returns the number of buddies in this group
|
||||||
|
*
|
||||||
* @return buddy count
|
* @return buddy count
|
||||||
*/
|
*/
|
||||||
public int getBuddyCount() {
|
public int getBuddyCount() {
|
||||||
return(buddies.size());
|
return (buddies.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method returns the buddies in this group
|
/**
|
||||||
* @return a Collection of {@link Buddy} objects
|
* This method returns the buddies in this group
|
||||||
|
*
|
||||||
|
* @return a Collection of {@link Buddy} objects
|
||||||
*/
|
*/
|
||||||
public java.util.Collection getBuddies() {
|
public java.util.Collection getBuddies() {
|
||||||
java.util.Collection cReturn = new java.util.Vector(buddies);
|
java.util.Collection cReturn = new java.util.Vector(buddies);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -25,98 +25,105 @@
|
||||||
|
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/** This response is delivered to a {@link JaimEventListener } when an instant message is received
|
/**
|
||||||
|
* This response is delivered to a {@link JaimEventListener } when an instant message is received
|
||||||
|
*
|
||||||
* @author paulw
|
* @author paulw
|
||||||
* @version $Revision: 1.6 $
|
* @version $Revision: 1.6 $
|
||||||
*/
|
*/
|
||||||
public class IMTocResponse extends TocResponse implements TocResponseHandler {
|
public class IMTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
public static final String RESPONSE_TYPE = "IM_IN";
|
||||||
String from;
|
String from;
|
||||||
boolean autoResponse;
|
boolean autoResponse;
|
||||||
String msg;
|
String msg;
|
||||||
|
|
||||||
public static final String RESPONSE_TYPE="IM_IN";
|
/**
|
||||||
|
* Creates new TocIMResponse
|
||||||
/** Creates new TocIMResponse */
|
*/
|
||||||
public IMTocResponse() {
|
public IMTocResponse() {
|
||||||
from="";
|
from = "";
|
||||||
msg="";
|
msg = "";
|
||||||
autoResponse=false;
|
autoResponse = false;
|
||||||
}
|
|
||||||
|
|
||||||
/** Obtain the name of the buddy who sent this instant message
|
|
||||||
* @return The senders name
|
|
||||||
*/
|
|
||||||
public String getFrom()
|
|
||||||
{
|
|
||||||
return(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Obtain the message
|
|
||||||
* @return The message
|
|
||||||
* @see Utils#stripHTML
|
|
||||||
*/
|
|
||||||
public String getMsg()
|
|
||||||
{
|
|
||||||
return(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Is this response an automatically generated response?
|
|
||||||
* @return true if this is an automatically generated response
|
|
||||||
*/
|
|
||||||
public boolean getAutoResponse()
|
|
||||||
{
|
|
||||||
return(autoResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse an incoming IM response string
|
/**
|
||||||
* @param str The string to be parsed
|
* Obtain the name of the buddy who sent this instant message
|
||||||
*/
|
*
|
||||||
public TocResponse parseString(java.lang.String str) {
|
* @return The senders name
|
||||||
IMTocResponse tr=new IMTocResponse();
|
*/
|
||||||
tr.doParse(str);
|
public String getFrom() {
|
||||||
return(tr);
|
return (from);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
/**
|
||||||
{
|
* Obtain the message
|
||||||
cmd=str;
|
*
|
||||||
int colonPos=str.indexOf(':');
|
* @return The message
|
||||||
if (colonPos!=-1)
|
* @see Utils#stripHTML
|
||||||
{
|
*/
|
||||||
str=str.substring(colonPos+1);
|
public String getMsg() {
|
||||||
colonPos=str.indexOf(':');
|
return (msg);
|
||||||
if (colonPos != -1)
|
}
|
||||||
{
|
|
||||||
from=str.substring(0,colonPos);
|
/**
|
||||||
str=str.substring(colonPos+1);
|
* Is this response an automatically generated response?
|
||||||
colonPos=str.indexOf(':');
|
*
|
||||||
if (str.charAt(0) == 'T')
|
* @return true if this is an automatically generated response
|
||||||
{
|
*/
|
||||||
autoResponse=true;
|
public boolean getAutoResponse() {
|
||||||
|
return (autoResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse an incoming IM response string
|
||||||
|
*
|
||||||
|
* @param str The string to be parsed
|
||||||
|
*/
|
||||||
|
public TocResponse parseString(java.lang.String str) {
|
||||||
|
IMTocResponse tr = new IMTocResponse();
|
||||||
|
tr.doParse(str);
|
||||||
|
return (tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doParse(String str) {
|
||||||
|
cmd = str;
|
||||||
|
int colonPos = str.indexOf(':');
|
||||||
|
if (colonPos != -1) {
|
||||||
|
str = str.substring(colonPos + 1);
|
||||||
|
colonPos = str.indexOf(':');
|
||||||
|
if (colonPos != -1) {
|
||||||
|
from = str.substring(0, colonPos);
|
||||||
|
str = str.substring(colonPos + 1);
|
||||||
|
colonPos = str.indexOf(':');
|
||||||
|
if (str.charAt(0) == 'T') {
|
||||||
|
autoResponse = true;
|
||||||
}
|
}
|
||||||
if (colonPos != -1)
|
if (colonPos != -1) {
|
||||||
{
|
msg = str.substring(colonPos + 1);
|
||||||
msg=str.substring(colonPos+1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Obtain the response type for response dispatching purposes
|
/**
|
||||||
|
* Obtain the response type for response dispatching purposes
|
||||||
|
*
|
||||||
* @return The response type
|
* @return The response type
|
||||||
*/
|
*/
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return(RESPONSE_TYPE);
|
return (RESPONSE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -19,24 +19,27 @@
|
||||||
|
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/** The JaimEvent object is delivered to all registered {@link JaimEventListener}
|
/**
|
||||||
* @see JaimConnection#addEventListener
|
* The JaimEvent object is delivered to all registered {@link JaimEventListener}
|
||||||
* @author paulw
|
*
|
||||||
|
* @author paulw
|
||||||
* @version $revision: $
|
* @version $revision: $
|
||||||
|
* @see JaimConnection#addEventListener
|
||||||
*/
|
*/
|
||||||
public class JaimEvent extends java.util.EventObject {
|
public class JaimEvent extends java.util.EventObject {
|
||||||
|
|
||||||
private TocResponse tocResponse;
|
private final TocResponse tocResponse;
|
||||||
|
|
||||||
/** Creates new JaimEvent */
|
/**
|
||||||
|
* Creates new JaimEvent
|
||||||
|
*/
|
||||||
public JaimEvent(Object source, TocResponse tocResponse) {
|
public JaimEvent(Object source, TocResponse tocResponse) {
|
||||||
super(source);
|
super(source);
|
||||||
this.tocResponse=tocResponse;
|
this.tocResponse = tocResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TocResponse getTocResponse()
|
public TocResponse getTocResponse() {
|
||||||
{
|
return (tocResponse);
|
||||||
return(tocResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -25,16 +25,20 @@
|
||||||
|
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/** A JaimEventListener receives JaimEvents from the JaimConnection class.
|
/**
|
||||||
|
* A JaimEventListener receives JaimEvents from the JaimConnection class.
|
||||||
* A {@link JaimEvent} contains a {@link TocResponse} object.
|
* A {@link JaimEvent} contains a {@link TocResponse} object.
|
||||||
* @author paulw
|
*
|
||||||
|
* @author paulw
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public interface JaimEventListener {
|
public interface JaimEventListener {
|
||||||
|
|
||||||
/** Receive an incoming {@link JaimEvent}
|
/**
|
||||||
*@param ev - The incoming event
|
* Receive an incoming {@link JaimEvent}
|
||||||
|
*
|
||||||
|
* @param ev - The incoming event
|
||||||
*/
|
*/
|
||||||
public void receiveEvent(JaimEvent ev);
|
void receiveEvent(JaimEvent ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,8 +26,7 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class JaimException extends java.lang.Exception {
|
public class JaimException extends java.lang.Exception {
|
||||||
|
@ -41,6 +40,7 @@ public class JaimException extends java.lang.Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an <code>JaimException</code> with the specified detail message.
|
* Constructs an <code>JaimException</code> with the specified detail message.
|
||||||
|
*
|
||||||
* @param msg the detail message.
|
* @param msg the detail message.
|
||||||
*/
|
*/
|
||||||
public JaimException(String msg) {
|
public JaimException(String msg) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -19,8 +19,7 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $version: $
|
* @version $version: $
|
||||||
*/
|
*/
|
||||||
public class JaimStateException extends JaimException {
|
public class JaimStateException extends JaimException {
|
||||||
|
@ -34,6 +33,7 @@ public class JaimStateException extends JaimException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an <code>JaimStateException</code> with the specified detail message.
|
* Constructs an <code>JaimStateException</code> with the specified detail message.
|
||||||
|
*
|
||||||
* @param msg the detail message.
|
* @param msg the detail message.
|
||||||
*/
|
*/
|
||||||
public JaimStateException(String msg) {
|
public JaimStateException(String msg) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -20,8 +20,7 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $version: $
|
* @version $version: $
|
||||||
*/
|
*/
|
||||||
public class JaimTimeoutException extends JaimException {
|
public class JaimTimeoutException extends JaimException {
|
||||||
|
@ -35,6 +34,7 @@ public class JaimTimeoutException extends JaimException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an <code>JaimTimeoutException</code> with the specified detail message.
|
* Constructs an <code>JaimTimeoutException</code> with the specified detail message.
|
||||||
|
*
|
||||||
* @param msg the detail message.
|
* @param msg the detail message.
|
||||||
*/
|
*/
|
||||||
public JaimTimeoutException(String msg) {
|
public JaimTimeoutException(String msg) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -27,24 +27,26 @@ package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a "pseudo" TOC response - it is delivered to JaimLib clients to indicate that login processing has been completed successfully.
|
* This is a "pseudo" TOC response - it is delivered to JaimLib clients to indicate that login processing has been completed successfully.
|
||||||
* @author wilko
|
*
|
||||||
|
* @author wilko
|
||||||
* @version: $revision: $
|
* @version: $revision: $
|
||||||
*/
|
*/
|
||||||
public class LoginCompleteTocResponse extends TocResponse {
|
public class LoginCompleteTocResponse extends TocResponse {
|
||||||
|
|
||||||
public static final String RESPONSE_TYPE="LOGINCOMPLETE";
|
public static final String RESPONSE_TYPE = "LOGINCOMPLETE";
|
||||||
|
|
||||||
/** Creates a new instance of LoginCompleteTocResponse */
|
/**
|
||||||
|
* Creates a new instance of LoginCompleteTocResponse
|
||||||
|
*/
|
||||||
public LoginCompleteTocResponse() {
|
public LoginCompleteTocResponse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return (RESPONSE_TYPE);
|
return (RESPONSE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return (RESPONSE_TYPE);
|
return (RESPONSE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,57 +26,58 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The NicTocResponse is used internally to manage the TOC signon process. It is not delivered to clients of {@link JaimConnection}
|
* The NicTocResponse is used internally to manage the TOC signon process. It is not delivered to clients of {@link JaimConnection}
|
||||||
* @author paulw
|
*
|
||||||
|
* @author paulw
|
||||||
* @version $Revision: 1.6 $
|
* @version $Revision: 1.6 $
|
||||||
*/
|
*/
|
||||||
public class NickTocResponse extends TocResponse implements TocResponseHandler {
|
public class NickTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
public static final String RESPONSE_TYPE = "NICK";
|
||||||
private String nickName;
|
private String nickName;
|
||||||
|
|
||||||
public static final String RESPONSE_TYPE="NICK";
|
|
||||||
|
/**
|
||||||
|
* Creates new NickTocResponse
|
||||||
/** Creates new NickTocResponse */
|
*/
|
||||||
public NickTocResponse() {
|
public NickTocResponse() {
|
||||||
nickName="";
|
nickName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TocResponse parseString(java.lang.String str) {
|
public TocResponse parseString(java.lang.String str) {
|
||||||
NickTocResponse tr=new NickTocResponse();
|
NickTocResponse tr = new NickTocResponse();
|
||||||
tr.doParse(str);
|
tr.doParse(str);
|
||||||
return(tr);
|
return (tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
private void doParse(String str) {
|
||||||
{
|
int colonPos = str.indexOf(':');
|
||||||
int colonPos=str.indexOf(':');
|
|
||||||
|
if (colonPos != -1) {
|
||||||
if (colonPos != -1)
|
nickName = str.substring(colonPos + 1);
|
||||||
{
|
}
|
||||||
nickName=str.substring(colonPos+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNickName()
|
public String getNickName() {
|
||||||
{
|
return (nickName);
|
||||||
return(nickName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return RESPONSE_TYPE;
|
return RESPONSE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return(Response.equalsIgnoreCase(RESPONSE_TYPE));
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -27,54 +27,54 @@ package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SignOnTocResponse is used internally to manage the TOC signon process. It is not delivered to clients of {@link JaimConnection}
|
* The SignOnTocResponse is used internally to manage the TOC signon process. It is not delivered to clients of {@link JaimConnection}
|
||||||
* @author paulw
|
*
|
||||||
|
* @author paulw
|
||||||
* @version $Revision: 1.5 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
public class SignOnTocResponse extends TocResponse implements TocResponseHandler {
|
public class SignOnTocResponse extends TocResponse implements TocResponseHandler {
|
||||||
|
|
||||||
|
public static final String RESPONSE_TYPE = "SIGN_ON";
|
||||||
String version;
|
String version;
|
||||||
|
|
||||||
public static final String RESPONSE_TYPE="SIGN_ON";
|
|
||||||
|
/**
|
||||||
|
* Creates new SignOnTocResponse
|
||||||
/** Creates new SignOnTocResponse */
|
*/
|
||||||
public SignOnTocResponse() {
|
public SignOnTocResponse() {
|
||||||
version="";
|
version = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResponseType() {
|
public String getResponseType() {
|
||||||
return(RESPONSE_TYPE);
|
return (RESPONSE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getVersion()
|
protected String getVersion() {
|
||||||
{
|
return (version);
|
||||||
return(version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TocResponse parseString(String str)
|
public TocResponse parseString(String str) {
|
||||||
{
|
SignOnTocResponse tr = new SignOnTocResponse();
|
||||||
SignOnTocResponse tr=new SignOnTocResponse();
|
|
||||||
tr.doParse(str);
|
tr.doParse(str);
|
||||||
return(tr);
|
return (tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doParse(String str)
|
private void doParse(String str) {
|
||||||
{
|
cmd = str;
|
||||||
cmd=str;
|
int colonpos = str.indexOf(':');
|
||||||
int colonpos=str.indexOf(':');
|
if (colonpos != -1) {
|
||||||
if (colonpos != -1)
|
version = str.substring(colonpos + 1);
|
||||||
{
|
|
||||||
version=str.substring(colonpos+1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
|
* Returns true if this response handler can handle the specified response.
|
||||||
|
*
|
||||||
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
* @return true if the response can be handled
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String Response) {
|
public boolean canHandle(String Response) {
|
||||||
return(Response.equalsIgnoreCase(RESPONSE_TYPE));
|
return (Response.equalsIgnoreCase(RESPONSE_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -28,40 +28,38 @@ package com.wilko.jaim;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class TocAddBuddyCommand extends TocCommand {
|
public class TocAddBuddyCommand extends TocCommand {
|
||||||
|
|
||||||
private static String CMD="toc_add_buddy";
|
private static final String CMD = "toc_add_buddy";
|
||||||
|
|
||||||
Vector buddyList;
|
Vector buddyList;
|
||||||
|
|
||||||
/** Creates new TocAddBuddyCommand */
|
/**
|
||||||
|
* Creates new TocAddBuddyCommand
|
||||||
|
*/
|
||||||
public TocAddBuddyCommand() {
|
public TocAddBuddyCommand() {
|
||||||
buddyList=new Vector();
|
buddyList = new Vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBuddy(String buddy)
|
public void addBuddy(String buddy) {
|
||||||
{
|
|
||||||
buddyList.add(Utils.normalise(buddy));
|
buddyList.add(Utils.normalise(buddy));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
StringBuffer output = new StringBuffer(CMD);
|
||||||
StringBuffer output=new StringBuffer(CMD);
|
for (int i = 0; i < buddyList.size(); i++) {
|
||||||
for (int i=0;i<buddyList.size();i++)
|
|
||||||
{
|
|
||||||
output.append(' ');
|
output.append(' ');
|
||||||
output.append((String)buddyList.elementAt(i));
|
output.append((String) buddyList.elementAt(i));
|
||||||
}
|
}
|
||||||
return(output.toString());
|
return (output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(toString().getBytes());
|
return (toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -28,40 +28,38 @@ package com.wilko.jaim;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class TocAddDenyCommand extends TocCommand {
|
public class TocAddDenyCommand extends TocCommand {
|
||||||
|
|
||||||
private static String CMD="toc_add_deny";
|
private static final String CMD = "toc_add_deny";
|
||||||
|
|
||||||
Vector buddyList;
|
Vector buddyList;
|
||||||
|
|
||||||
/** Creates new TocAddBuddyCommand */
|
/**
|
||||||
|
* Creates new TocAddBuddyCommand
|
||||||
|
*/
|
||||||
public TocAddDenyCommand() {
|
public TocAddDenyCommand() {
|
||||||
buddyList=new Vector();
|
buddyList = new Vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDeny(String buddy)
|
public void addDeny(String buddy) {
|
||||||
{
|
|
||||||
buddyList.add(Utils.normalise(buddy));
|
buddyList.add(Utils.normalise(buddy));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
StringBuffer output = new StringBuffer(CMD);
|
||||||
StringBuffer output=new StringBuffer(CMD);
|
for (int i = 0; i < buddyList.size(); i++) {
|
||||||
for (int i=0;i<buddyList.size();i++)
|
|
||||||
{
|
|
||||||
output.append(' ');
|
output.append(' ');
|
||||||
output.append((String)buddyList.elementAt(i));
|
output.append((String) buddyList.elementAt(i));
|
||||||
}
|
}
|
||||||
return(output.toString());
|
return (output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(toString().getBytes());
|
return (toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -28,40 +28,38 @@ package com.wilko.jaim;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.1 $
|
||||||
*/
|
*/
|
||||||
public class TocAddPermitCommand extends TocCommand {
|
public class TocAddPermitCommand extends TocCommand {
|
||||||
|
|
||||||
private static String CMD="toc_add_permit";
|
private static final String CMD = "toc_add_permit";
|
||||||
|
|
||||||
Vector buddyList;
|
Vector buddyList;
|
||||||
|
|
||||||
/** Creates new TocAddBuddyCommand */
|
/**
|
||||||
|
* Creates new TocAddBuddyCommand
|
||||||
|
*/
|
||||||
public TocAddPermitCommand() {
|
public TocAddPermitCommand() {
|
||||||
buddyList=new Vector();
|
buddyList = new Vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPermit(String buddy)
|
public void addPermit(String buddy) {
|
||||||
{
|
|
||||||
buddyList.add(Utils.normalise(buddy));
|
buddyList.add(Utils.normalise(buddy));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
StringBuffer output = new StringBuffer(CMD);
|
||||||
StringBuffer output=new StringBuffer(CMD);
|
for (int i = 0; i < buddyList.size(); i++) {
|
||||||
for (int i=0;i<buddyList.size();i++)
|
|
||||||
{
|
|
||||||
output.append(' ');
|
output.append(' ');
|
||||||
output.append((String)buddyList.elementAt(i));
|
output.append((String) buddyList.elementAt(i));
|
||||||
}
|
}
|
||||||
return(output.toString());
|
return (output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(toString().getBytes());
|
return (toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,28 +26,28 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
public class TocChatJoinCommand extends TocCommand {
|
public class TocChatJoinCommand extends TocCommand {
|
||||||
|
|
||||||
private int exchange;
|
private final int exchange;
|
||||||
private String roomName;
|
private final String roomName;
|
||||||
|
|
||||||
/** Creates new TocIMCommand */
|
/**
|
||||||
|
* Creates new TocIMCommand
|
||||||
|
*/
|
||||||
public TocChatJoinCommand(int exchange, String roomName) {
|
public TocChatJoinCommand(int exchange, String roomName) {
|
||||||
this.exchange=exchange;
|
this.exchange = exchange;
|
||||||
this.roomName=roomName;
|
this.roomName = roomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return ("toc_chat_join " + exchange + " " + roomName);
|
||||||
return ("toc_chat_join "+exchange+" "+roomName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(this.toString().getBytes());
|
return (this.toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,18 +26,19 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public abstract class TocCommand {
|
public abstract class TocCommand {
|
||||||
|
|
||||||
/** Creates new TocCommand */
|
/**
|
||||||
|
* Creates new TocCommand
|
||||||
|
*/
|
||||||
public TocCommand() {
|
public TocCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public byte[] getBytes();
|
abstract public byte[] getBytes();
|
||||||
|
|
||||||
abstract public String toString();
|
abstract public String toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,36 +26,34 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class TocEvilCommand extends TocCommand {
|
public class TocEvilCommand extends TocCommand {
|
||||||
|
|
||||||
private String buddy;
|
private final String buddy;
|
||||||
private boolean anonymous;
|
private final boolean anonymous;
|
||||||
|
|
||||||
/** Creates new TocEvilCommand */
|
/**
|
||||||
|
* Creates new TocEvilCommand
|
||||||
|
*/
|
||||||
public TocEvilCommand(String buddy, boolean anonymous) {
|
public TocEvilCommand(String buddy, boolean anonymous) {
|
||||||
this.buddy=Utils.normalise(buddy);
|
this.buddy = Utils.normalise(buddy);
|
||||||
this.anonymous=anonymous;
|
this.anonymous = anonymous;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
String ret = "toc_evil " + buddy;
|
||||||
String ret="toc_evil "+buddy;
|
if (anonymous) {
|
||||||
if (anonymous)
|
ret = ret + " anon";
|
||||||
{
|
} else
|
||||||
ret=ret+" anon";
|
ret = ret + " norm";
|
||||||
}
|
|
||||||
else
|
return (ret);
|
||||||
ret=ret+" norm";
|
|
||||||
|
|
||||||
return(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return toString().getBytes();
|
return toString().getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -39,32 +39,31 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $version: $
|
* @version $version: $
|
||||||
*/
|
*/
|
||||||
public class TocGetInfoCommand extends TocCommand {
|
public class TocGetInfoCommand extends TocCommand {
|
||||||
|
|
||||||
private String username;
|
private static final String CMD = "toc_get_info ";
|
||||||
|
private final String username;
|
||||||
private static String CMD="toc_get_info ";
|
|
||||||
/** Creates new TocGetInfoCommand
|
/**
|
||||||
*@param username The screen name for whom information is requested
|
* Creates new TocGetInfoCommand
|
||||||
*
|
*
|
||||||
|
* @param username The screen name for whom information is requested
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public TocGetInfoCommand(String username) {
|
public TocGetInfoCommand(String username) {
|
||||||
this.username=Utils.normalise(username);
|
this.username = Utils.normalise(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return (CMD + username);
|
||||||
return(CMD+username);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(toString().getBytes());
|
return (toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,33 +26,33 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
public class TocIMCommand extends TocCommand {
|
public class TocIMCommand extends TocCommand {
|
||||||
|
|
||||||
private String recipient;
|
private final String recipient;
|
||||||
private String msg;
|
private final String msg;
|
||||||
private String auto;
|
private final String auto;
|
||||||
|
|
||||||
/** Creates new TocIMCommand */
|
/**
|
||||||
public TocIMCommand(String recipient, String msg,boolean autoMessage) {
|
* Creates new TocIMCommand
|
||||||
this.recipient=Utils.normalise(recipient);
|
*/
|
||||||
this.msg=Utils.encodeText(msg);
|
public TocIMCommand(String recipient, String msg, boolean autoMessage) {
|
||||||
|
this.recipient = Utils.normalise(recipient);
|
||||||
|
this.msg = Utils.encodeText(msg);
|
||||||
if (autoMessage)
|
if (autoMessage)
|
||||||
auto=" auto";
|
auto = " auto";
|
||||||
else
|
else
|
||||||
auto="";
|
auto = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return ("toc_send_im " + recipient + " " + msg + auto);
|
||||||
return ("toc_send_im "+recipient+" "+msg+auto);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(this.toString().getBytes());
|
return (this.toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,25 +26,25 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
public class TocInitDoneCommand extends TocCommand {
|
public class TocInitDoneCommand extends TocCommand {
|
||||||
|
|
||||||
private static final String CMD="toc_init_done";
|
private static final String CMD = "toc_init_done";
|
||||||
|
|
||||||
/** Creates new TocInitDoneCommand */
|
/**
|
||||||
|
* Creates new TocInitDoneCommand
|
||||||
|
*/
|
||||||
public TocInitDoneCommand() {
|
public TocInitDoneCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(CMD.getBytes());
|
return (CMD.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return (CMD);
|
||||||
return(CMD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,24 +26,21 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.5 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
public abstract class TocResponse {
|
public abstract class TocResponse {
|
||||||
|
|
||||||
protected String cmd;
|
protected String cmd;
|
||||||
|
|
||||||
public TocResponse()
|
public TocResponse() {
|
||||||
{
|
cmd = "";
|
||||||
cmd="";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return (cmd);
|
||||||
return(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getResponseType();
|
public abstract String getResponseType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,8 +26,7 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.5 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -36,47 +35,41 @@ import java.util.Vector;
|
||||||
public abstract class TocResponseFactory {
|
public abstract class TocResponseFactory {
|
||||||
|
|
||||||
static Vector responseHandlers = new Vector();
|
static Vector responseHandlers = new Vector();
|
||||||
|
|
||||||
/** Creates new TocResponseFactory */
|
/**
|
||||||
|
* Creates new TocResponseFactory
|
||||||
|
*/
|
||||||
public TocResponseFactory() {
|
public TocResponseFactory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addResponseHandler(TocResponseHandler h)
|
public static void addResponseHandler(TocResponseHandler h) {
|
||||||
{
|
synchronized (responseHandlers) {
|
||||||
synchronized (responseHandlers)
|
|
||||||
{
|
|
||||||
responseHandlers.add(h);
|
responseHandlers.add(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static TocResponse createResponse(byte[] b)
|
static TocResponse createResponse(byte[] b) {
|
||||||
{
|
TocResponse tr = null;
|
||||||
TocResponse tr=null;
|
String strversion = new String(b);
|
||||||
String strversion=new String(b);
|
int colonpos = strversion.indexOf(':');
|
||||||
int colonpos=strversion.indexOf(':');
|
if (colonpos != -1) {
|
||||||
if (colonpos != -1)
|
String firstWord = strversion.substring(0, colonpos);
|
||||||
{
|
int i = 0;
|
||||||
String firstWord=strversion.substring(0,colonpos);
|
synchronized (responseHandlers) {
|
||||||
int i=0;
|
while ((i < responseHandlers.size()) && (tr == null)) {
|
||||||
synchronized (responseHandlers)
|
TocResponseHandler h = (TocResponseHandler) responseHandlers.elementAt(i);
|
||||||
{
|
if (h.canHandle(firstWord)) {
|
||||||
while ((i<responseHandlers.size())&&(tr==null))
|
tr = h.parseString(strversion);
|
||||||
{
|
|
||||||
TocResponseHandler h=(TocResponseHandler)responseHandlers.elementAt(i);
|
|
||||||
if (h.canHandle(firstWord))
|
|
||||||
{
|
|
||||||
tr=h.parseString(strversion);
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tr==null)
|
if (tr == null) {
|
||||||
{
|
GenericTocResponse gtr = new GenericTocResponse();
|
||||||
GenericTocResponse gtr=new GenericTocResponse();
|
tr = gtr.parseString(strversion);
|
||||||
tr=gtr.parseString(strversion);
|
|
||||||
}
|
}
|
||||||
return(tr);
|
return (tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -20,25 +20,28 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $revision: $
|
* @version $revision: $
|
||||||
*/
|
*/
|
||||||
public interface TocResponseHandler {
|
public interface TocResponseHandler {
|
||||||
|
|
||||||
/** Returns true if this response handler can handle the specified response.
|
/**
|
||||||
*@param Response - the response string from TOC. This is the part of the response before the first ':'
|
* Returns true if this response handler can handle the specified response.
|
||||||
*@return true if the response can be handled
|
*
|
||||||
|
* @param Response - the response string from TOC. This is the part of the response before the first ':'
|
||||||
|
* @return true if the response can be handled
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public boolean canHandle(String Response);
|
boolean canHandle(String Response);
|
||||||
|
|
||||||
/** Parse the provided response
|
/**
|
||||||
*@param Response - the response from the TOC server. This is the full TOC response string
|
* Parse the provided response
|
||||||
*@return - A TocResponse object that represents this response
|
*
|
||||||
|
* @param Response - the response from the TOC server. This is the full TOC response string
|
||||||
|
* @return - A TocResponse object that represents this response
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public TocResponse parseString(String Response);
|
TocResponse parseString(String Response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,31 +26,31 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $version: $
|
* @version $version: $
|
||||||
*/
|
*/
|
||||||
public class TocSetAwayCommand extends TocCommand {
|
public class TocSetAwayCommand extends TocCommand {
|
||||||
|
|
||||||
private String awayMsg;
|
private static final String CMD = "toc_set_away ";
|
||||||
|
private final String awayMsg;
|
||||||
private static String CMD="toc_set_away ";
|
|
||||||
/** Creates new TocSetInfoCommand
|
/**
|
||||||
|
* Creates new TocSetInfoCommand
|
||||||
|
*
|
||||||
* @param awayMsg The away message for this user. May contain HTML. To cancel "away" status set the awayMsg to ""
|
* @param awayMsg The away message for this user. May contain HTML. To cancel "away" status set the awayMsg to ""
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public TocSetAwayCommand(String awayMsg) {
|
public TocSetAwayCommand(String awayMsg) {
|
||||||
this.awayMsg=Utils.encodeText(awayMsg);
|
this.awayMsg = Utils.encodeText(awayMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return (CMD + awayMsg);
|
||||||
return(CMD+awayMsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(toString().getBytes());
|
return (toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -28,47 +28,42 @@ package com.wilko.jaim;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
*/
|
*/
|
||||||
public class TocSetConfigCommand extends TocCommand {
|
public class TocSetConfigCommand extends TocCommand {
|
||||||
|
|
||||||
private StringBuffer config;
|
|
||||||
|
|
||||||
private static String CMD="toc_set_config ";
|
|
||||||
|
|
||||||
/** Creates a new instance of TocSetConfigCommand */
|
private static final String CMD = "toc_set_config ";
|
||||||
|
private final StringBuffer config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of TocSetConfigCommand
|
||||||
|
*/
|
||||||
public TocSetConfigCommand() {
|
public TocSetConfigCommand() {
|
||||||
config=new StringBuffer();
|
config = new StringBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGroup(Group g)
|
public void addGroup(Group g) {
|
||||||
{
|
config.append("g " + g.getName() + "\n");
|
||||||
config.append("g "+g.getName()+"\n");
|
Enumeration buddies = g.enumerateBuddies();
|
||||||
Enumeration buddies=g.enumerateBuddies();
|
while (buddies.hasMoreElements()) {
|
||||||
while (buddies.hasMoreElements())
|
Buddy b = (Buddy) buddies.nextElement();
|
||||||
{
|
config.append("b " + b.getName() + "\n");
|
||||||
Buddy b = (Buddy)buddies.nextElement();
|
if (b.getPermit()) {
|
||||||
config.append("b "+b.getName()+"\n");
|
config.append("p " + b.getName() + "\n");
|
||||||
if (b.getPermit())
|
|
||||||
{
|
|
||||||
config.append("p "+b.getName()+"\n");
|
|
||||||
}
|
}
|
||||||
if (b.getDeny())
|
if (b.getDeny()) {
|
||||||
{
|
config.append("d " + b.getName() + "\n");
|
||||||
config.append("d "+b.getName()+"\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return (CMD + '"' + config.toString() + '"');
|
||||||
return(CMD+'"'+config.toString()+'"');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(toString().getBytes());
|
return (toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -25,29 +25,29 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $version: $
|
* @version $version: $
|
||||||
*/
|
*/
|
||||||
public class TocSetIdleCommand extends TocCommand {
|
public class TocSetIdleCommand extends TocCommand {
|
||||||
|
|
||||||
private int idle;
|
private static final String CMD = "toc_set_idle ";
|
||||||
private static final String CMD="toc_set_idle ";
|
private final int idle;
|
||||||
|
|
||||||
/** Creates new TocSetIdleCommand
|
/**
|
||||||
*@param idleSecs - the period for which the user has been idle
|
* Creates new TocSetIdleCommand
|
||||||
|
*
|
||||||
|
* @param idleSecs - the period for which the user has been idle
|
||||||
*/
|
*/
|
||||||
public TocSetIdleCommand(int idleSecs) {
|
public TocSetIdleCommand(int idleSecs) {
|
||||||
idle=idleSecs;
|
idle = idleSecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return (CMD + idle);
|
||||||
return(CMD+idle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(toString().getBytes());
|
return (toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,31 +26,31 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $version: $
|
* @version $version: $
|
||||||
*/
|
*/
|
||||||
public class TocSetInfoCommand extends TocCommand {
|
public class TocSetInfoCommand extends TocCommand {
|
||||||
|
|
||||||
private String information;
|
private static final String CMD = "toc_set_info ";
|
||||||
|
private final String information;
|
||||||
private static String CMD="toc_set_info ";
|
|
||||||
/** Creates new TocSetInfoCommand
|
/**
|
||||||
*@param information The information about this user can be located. May contain HTML
|
* Creates new TocSetInfoCommand
|
||||||
|
*
|
||||||
|
* @param information The information about this user can be located. May contain HTML
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public TocSetInfoCommand(String information) {
|
public TocSetInfoCommand(String information) {
|
||||||
this.information=Utils.encodeText(information);
|
this.information = Utils.encodeText(information);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
return (CMD + information);
|
||||||
return(CMD+information);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return(toString().getBytes());
|
return (toString().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,38 +26,37 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author paulw
|
||||||
* @author paulw
|
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class TocSignonCommand extends TocCommand {
|
public class TocSignonCommand extends TocCommand {
|
||||||
|
|
||||||
private String server;
|
private static final String AGENTNAME = "jaim01";
|
||||||
private String username;
|
private final String server;
|
||||||
private String password;
|
private final String username;
|
||||||
private int port;
|
private final String password;
|
||||||
|
private final int port;
|
||||||
private static final String AGENTNAME="jaim01";
|
|
||||||
|
/**
|
||||||
/** Creates new TocSignonCommand */
|
* Creates new TocSignonCommand
|
||||||
|
*/
|
||||||
public TocSignonCommand(String server, int port, String username, String password) {
|
public TocSignonCommand(String server, int port, String username, String password) {
|
||||||
this.server=server;
|
this.server = server;
|
||||||
this.port=port;
|
this.port = port;
|
||||||
this.username=Utils.normalise(username);
|
this.username = Utils.normalise(username);
|
||||||
this.password=Utils.roast(password);
|
this.password = Utils.roast(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return toString().getBytes();
|
return toString().getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
String temp = "toc_signon login.oscar.aol.com 5159 " + username + " " + password + " english " + AGENTNAME;
|
||||||
String temp="toc_signon login.oscar.aol.com 5159 "+username+" "+password+" english "+AGENTNAME;
|
return (temp);
|
||||||
return(temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void parseString(java.lang.String str) {
|
public void parseString(java.lang.String str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -26,100 +26,92 @@
|
||||||
package com.wilko.jaim;
|
package com.wilko.jaim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author paulw
|
* @author paulw
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
private static final String roastKey="Tic/Toc";
|
private static final String roastKey = "Tic/Toc";
|
||||||
private static final int roastLen=7;
|
private static final int roastLen = 7;
|
||||||
|
|
||||||
/** convert a buddy name to normalised format - remove spaces and convert to lower case
|
/**
|
||||||
|
* convert a buddy name to normalised format - remove spaces and convert to lower case
|
||||||
|
*
|
||||||
* @param input The un-normalised buddy name
|
* @param input The un-normalised buddy name
|
||||||
* @return the normalised buddy name
|
* @return the normalised buddy name
|
||||||
*/
|
*/
|
||||||
public static String normalise(java.lang.String input) {
|
public static String normalise(java.lang.String input) {
|
||||||
StringBuffer output=new StringBuffer();
|
StringBuffer output = new StringBuffer();
|
||||||
String temp=input.toLowerCase();
|
String temp = input.toLowerCase();
|
||||||
for (int i=0;i<input.length();i++)
|
for (int i = 0; i < input.length(); i++) {
|
||||||
{
|
char c = temp.charAt(i);
|
||||||
char c=temp.charAt(i);
|
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) {
|
||||||
if ((c>= '0' && c<='9')||(c>='a' && c<='z'))
|
|
||||||
{
|
|
||||||
output.append(c);
|
output.append(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(output.toString());
|
return (output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Roast a password using the AOL roasting protocol
|
/**
|
||||||
|
* Roast a password using the AOL roasting protocol
|
||||||
|
*
|
||||||
* @param password The password to be roasted
|
* @param password The password to be roasted
|
||||||
* @return The roasted password
|
* @return The roasted password
|
||||||
*/
|
*/
|
||||||
public static String roast(java.lang.String password) {
|
public static String roast(java.lang.String password) {
|
||||||
char[] hexChars={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
|
char[] hexChars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
|
|
||||||
StringBuffer temppw=new StringBuffer();
|
StringBuffer temppw = new StringBuffer();
|
||||||
temppw.append("0x");
|
temppw.append("0x");
|
||||||
for (int i=0;i<password.length();i++)
|
for (int i = 0; i < password.length(); i++) {
|
||||||
{
|
int roastedByte = password.charAt(i) ^ roastKey.charAt(i % roastLen);
|
||||||
int roastedByte=password.charAt(i)^roastKey.charAt(i%roastLen);
|
|
||||||
|
temppw.append(hexChars[(roastedByte >> 4) & 0x0f]);
|
||||||
temppw.append(hexChars[(roastedByte>>4)&0x0f]);
|
temppw.append(hexChars[roastedByte & 0x0f]);
|
||||||
temppw.append(hexChars[roastedByte&0x0f]);
|
|
||||||
}
|
}
|
||||||
return(temppw.toString());
|
return (temppw.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method performs a simple HTML strip on text. It looks for < characters and then skips input until a matching > is found.
|
/**
|
||||||
|
* This method performs a simple HTML strip on text. It looks for < characters and then skips input until a matching > is found.
|
||||||
* This may fail if the HTML tag contains an embedded '>'
|
* This may fail if the HTML tag contains an embedded '>'
|
||||||
|
*
|
||||||
* @param input The text to have HTML stripped
|
* @param input The text to have HTML stripped
|
||||||
* @return The text stripped of html
|
* @return The text stripped of html
|
||||||
*/
|
*/
|
||||||
public static String stripHTML(java.lang.String input)
|
public static String stripHTML(java.lang.String input) {
|
||||||
{
|
StringBuffer output = new StringBuffer();
|
||||||
StringBuffer output=new StringBuffer();
|
boolean inHTML = false;
|
||||||
boolean inHTML=false;
|
for (int i = 0; i < input.length(); i++) {
|
||||||
for (int i=0;i<input.length();i++)
|
char c = input.charAt(i);
|
||||||
{
|
if (c == '<') {
|
||||||
char c=input.charAt(i);
|
inHTML = true;
|
||||||
if (c=='<')
|
} else {
|
||||||
{
|
if (c == '>') {
|
||||||
inHTML=true;
|
inHTML = false;
|
||||||
}
|
} else {
|
||||||
else
|
if (!inHTML) {
|
||||||
{
|
|
||||||
if (c=='>') {
|
|
||||||
inHTML=false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!inHTML)
|
|
||||||
{
|
|
||||||
output.append(c);
|
output.append(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(output.toString());
|
return (output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Encode a text message so that it is suitable for transmission using toc_send_im
|
/**
|
||||||
|
* Encode a text message so that it is suitable for transmission using toc_send_im
|
||||||
*
|
*
|
||||||
* @param input The text to be encoded
|
* @param input The text to be encoded
|
||||||
* @return The encoded text
|
* @return The encoded text
|
||||||
*/
|
*/
|
||||||
public static String encodeText(String input)
|
public static String encodeText(String input) {
|
||||||
{
|
StringBuffer output = new StringBuffer("\"");
|
||||||
StringBuffer output=new StringBuffer("\"");
|
for (int i = 0; i < input.length(); i++) {
|
||||||
for (int i=0;i<input.length();i++)
|
char c = input.charAt(i);
|
||||||
{
|
switch (c) {
|
||||||
char c=input.charAt(i);
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '\"':
|
case '\"':
|
||||||
case '(':
|
case '(':
|
||||||
case ')':
|
case ')':
|
||||||
|
@ -134,10 +126,10 @@ public class Utils {
|
||||||
}
|
}
|
||||||
output.append(c);
|
output.append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
output.append('\"');
|
output.append('\"');
|
||||||
return(output.toString());
|
return (output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,13 @@
|
||||||
|
|
||||||
package com.wilko.jaimtest;
|
package com.wilko.jaimtest;
|
||||||
|
|
||||||
import java.net.*;
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
import com.wilko.jaim.*;
|
import com.wilko.jaim.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author paulw
|
* @author paulw
|
||||||
|
|
Loading…
Reference in a new issue