irc
Class IRCServer

java.lang.Object
  |
  +--irc.IRCObject
        |
        +--irc.IRCServer
All Implemented Interfaces:
Server, ServerProtocolListener

public class IRCServer
extends IRCObject
implements Server, ServerProtocolListener

The IRC server.


Field Summary
 
Fields inherited from class irc.IRCObject
_ircConfiguration
 
Constructor Summary
IRCServer(IRCConfiguration config, java.lang.String nick, java.lang.String altNick, java.lang.String userName, java.lang.String name)
          Create a new IRCServer.
 
Method Summary
 void addIgnore(java.lang.String nick)
          Ignore the given nick.
 void addReplyServerListener(ReplyServerListener l)
          Add a reply listener.
 void addServerListener(ServerListener l)
          Add a server listener.
 void connect()
          Try to connect to the server, using default configuration.
 void connected()
          The server is now connected.
 void connectionFailed(java.lang.String message)
          The connection coulnd't be established.
 void disconnect()
          Disconnect from the irc server.
 void disconnected()
          Connection to server has been lost.
 void enumerateSourcesAsCreated(ServerListener lis)
          Enumerate all sources, as if they were created and notified to the given listener.
 void execute(java.lang.String str)
          Execute the given command on the remote server.
 java.util.Enumeration getChanLists()
          Get all the chanlists.
 char[][] getChannelModes()
          Get an array of all known A,B,C,D channel modes.
 char[] getChannelPrefixes()
          Get an array of all known channel prefixes.
 java.util.Enumeration getChannels()
          Get all the channels.
 Source getDefaultSource()
          Get the default server source, or null if no default source is defined.
 int getLocalPort()
          Get the local port of the remote connection.
 java.lang.String getMode()
          Get the current status mode.
 java.lang.String getNick()
          Get the nickname on this server.
 java.lang.String getNickMode(java.lang.String prefix)
          Get the nick mode associated with the given nick prefix.
 char[] getNickModes()
          Get an array of all known nickname modes.
 java.lang.String getNickPrefix(java.lang.String mode)
          Get the nick prefix associated with the given nick mode.
 char[] getNickPrefixes()
          Get an array of all known nickname prefixes.
 java.util.Enumeration getQueries()
          Get all the queries.
 Query getQuery(java.lang.String nick, boolean local)
          Get the query from its name.
 java.lang.String getServerName()
          Get the server name.
 java.util.Enumeration getSources()
          Get an enumeration of all the sources associated with this server.
 Status getStatus()
          Get this server's status, or null if this server has no status.
 java.lang.String getUserName()
          Get the username on this server.
 boolean ignore(java.lang.String nick)
          Return true if this server is ignoring the given nick, false otherwise.
 boolean isConnected()
          Return true if connected to the server, false otherwise.
 void leave()
          Leave all sources, then leave the server.
 void leaveChanList(java.lang.String name)
          Request to leave the given channel list.
 void leaveChannel(java.lang.String name)
          Request to leave the given channel.
 void leaveQuery(java.lang.String name)
          Request to leave the given query.
 void leaveStatus(java.lang.String name)
          Request to leave the status.
 void messageReceived(java.lang.String prefix, java.lang.String command, java.lang.String[] params)
          A new server message has been received.
 void release()
          Release this object.
 void removeIgnore(java.lang.String nick)
          Remove the given list from the ignore list.
 void removeReplyServerListener(ReplyServerListener l)
          Remove a reply listener.
 void removeServerListener(ServerListener l)
          Remove a listener.
 void replyReceived(java.lang.String prefix, java.lang.String id, java.lang.String[] params)
          A new server numeric reply has been received.
 void say(java.lang.String destination, java.lang.String str)
          Say the specified string.
 void sendStatusMessage(java.lang.String msg)
          Send the given message to the server's status.
 void setDefaultSource(Source s)
          Set the default output source this server should use if the destination source is undefined.
 void setServers(java.lang.String[] host, int[] port, java.lang.String[] passWord)
          Set default configuration for the next connection.
 
Methods inherited from class irc.IRCObject
getColor, getIRCConfiguration, getText, getText, getText, getText, getTimeStamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IRCServer

public IRCServer(IRCConfiguration config,
                 java.lang.String nick,
                 java.lang.String altNick,
                 java.lang.String userName,
                 java.lang.String name)
Create a new IRCServer.

Parameters:
config - global IRCConfiguration.
nick - claimed nick.
altNick - claimed alternate nick.
userName - user name.
Method Detail

release

public void release()
Description copied from class: IRCObject
Release this object. No further method call can be performed on this object.

Overrides:
release in class IRCObject

getSources

public java.util.Enumeration getSources()
Description copied from interface: Server
Get an enumeration of all the sources associated with this server.

Specified by:
getSources in interface Server
Returns:
an enumeration of Source.

enumerateSourcesAsCreated

public void enumerateSourcesAsCreated(ServerListener lis)
Description copied from interface: Server
Enumerate all sources, as if they were created and notified to the given listener.

Specified by:
enumerateSourcesAsCreated in interface Server
Parameters:
lis - listener to call.

setDefaultSource

public void setDefaultSource(Source s)
Description copied from interface: Server
Set the default output source this server should use if the destination source is undefined.

Specified by:
setDefaultSource in interface Server
Parameters:
s - default source.

getDefaultSource

public Source getDefaultSource()
Get the default server source, or null if no default source is defined.

Returns:
default source.

setServers

public void setServers(java.lang.String[] host,
                       int[] port,
                       java.lang.String[] passWord)
Set default configuration for the next connection.

Parameters:
host - server host.
port - server port.
passWord - server password.

connect

public void connect()
Description copied from interface: Server
Try to connect to the server, using default configuration.

Specified by:
connect in interface Server

disconnect

public void disconnect()
Disconnect from the irc server.

Specified by:
disconnect in interface Server

isConnected

public boolean isConnected()
Return true if connected to the server, false otherwise.

Specified by:
isConnected in interface Server
Returns:
connected state.

connectionFailed

public void connectionFailed(java.lang.String message)
Description copied from interface: ServerProtocolListener
The connection coulnd't be established.

Specified by:
connectionFailed in interface ServerProtocolListener
Parameters:
message - error message.

getLocalPort

public int getLocalPort()
Get the local port of the remote connection.

Returns:
the local, client-side port of the remote connection.

connected

public void connected()
Description copied from interface: ServerProtocolListener
The server is now connected.

Specified by:
connected in interface ServerProtocolListener

disconnected

public void disconnected()
Description copied from interface: ServerProtocolListener
Connection to server has been lost.

Specified by:
disconnected in interface ServerProtocolListener

sendStatusMessage

public void sendStatusMessage(java.lang.String msg)
Description copied from interface: Server
Send the given message to the server's status.

Specified by:
sendStatusMessage in interface Server
Parameters:
msg - string to send to the status.

getChannels

public java.util.Enumeration getChannels()
Get all the channels.

Returns:
an enumeration of channels.

getQueries

public java.util.Enumeration getQueries()
Get all the queries.

Returns:
an enumeration of queries.

getChanLists

public java.util.Enumeration getChanLists()
Get all the chanlists.

Returns:
an enumeration of chanlists.

getQuery

public Query getQuery(java.lang.String nick,
                      boolean local)
Get the query from its name. If this query doesn't exist, it is created but not activated. The query cannot be get if the server is not connected.

Parameters:
local - true if this query has been created following a local request.
Returns:
query, or null if server was not connected.

leaveChannel

public void leaveChannel(java.lang.String name)
Request to leave the given channel.

Parameters:
name - channel name.

leaveQuery

public void leaveQuery(java.lang.String name)
Request to leave the given query.

Parameters:
name - query name.

leave

public void leave()
Description copied from interface: Server
Leave all sources, then leave the server.

Specified by:
leave in interface Server

leaveStatus

public void leaveStatus(java.lang.String name)
Request to leave the status. This will cause server leaving.

Parameters:
name - Status name. Unused.

leaveChanList

public void leaveChanList(java.lang.String name)
Request to leave the given channel list.

Parameters:
name - chanlist name.

getServerName

public java.lang.String getServerName()
Get the server name.


getStatus

public Status getStatus()
Get this server's status, or null if this server has no status.


addServerListener

public void addServerListener(ServerListener l)
Add a server listener.

Specified by:
addServerListener in interface Server
Parameters:
l - listener to add.

removeServerListener

public void removeServerListener(ServerListener l)
Remove a listener.

Specified by:
removeServerListener in interface Server
Parameters:
l - listener to remove.

addReplyServerListener

public void addReplyServerListener(ReplyServerListener l)
Add a reply listener.

Parameters:
l - listener to add.

removeReplyServerListener

public void removeReplyServerListener(ReplyServerListener l)
Remove a reply listener.

Parameters:
l - listener to remove.

getChannelPrefixes

public char[] getChannelPrefixes()
Get an array of all known channel prefixes.

Returns:
an array of all channel prefixes.

getNickPrefixes

public char[] getNickPrefixes()
Get an array of all known nickname prefixes.

Returns:
array of all nickname prefixes.

getNickModes

public char[] getNickModes()
Get an array of all known nickname modes.

Returns:
array of all nickname modes.

getChannelModes

public char[][] getChannelModes()
Get an array of all known A,B,C,D channel modes.

Returns:
array of all channel modes. This is an array of four char arrays.

getNickPrefix

public java.lang.String getNickPrefix(java.lang.String mode)
Get the nick prefix associated with the given nick mode.

Parameters:
mode - nick mode.
Returns:
nick prefix for this mode.

getNickMode

public java.lang.String getNickMode(java.lang.String prefix)
Get the nick mode associated with the given nick prefix.

Returns:
nick mode for this prefix.

replyReceived

public void replyReceived(java.lang.String prefix,
                          java.lang.String id,
                          java.lang.String[] params)
Description copied from interface: ServerProtocolListener
A new server numeric reply has been received.

Specified by:
replyReceived in interface ServerProtocolListener
Parameters:
prefix - reply prefix.
id - reply id.
params - reply parameters.

ignore

public boolean ignore(java.lang.String nick)
Return true if this server is ignoring the given nick, false otherwise.

Parameters:
nick - nick to test.

addIgnore

public void addIgnore(java.lang.String nick)
Ignore the given nick.

Parameters:
nick - nick to ignore.

removeIgnore

public void removeIgnore(java.lang.String nick)
Remove the given list from the ignore list.

Parameters:
nick - nick to remove from ignore list.

messageReceived

public void messageReceived(java.lang.String prefix,
                            java.lang.String command,
                            java.lang.String[] params)
Description copied from interface: ServerProtocolListener
A new server message has been received.

Specified by:
messageReceived in interface ServerProtocolListener
Parameters:
prefix - message prefix.
command - message command.
params - message parameters.

getNick

public java.lang.String getNick()
Description copied from interface: Server
Get the nickname on this server.

Specified by:
getNick in interface Server
Returns:
the nickname on the server.

getUserName

public java.lang.String getUserName()
Description copied from interface: Server
Get the username on this server.

Specified by:
getUserName in interface Server
Returns:
the username on this server.

getMode

public java.lang.String getMode()
Get the current status mode.

Returns:
status mode.

say

public void say(java.lang.String destination,
                java.lang.String str)
Description copied from interface: Server
Say the specified string. This string is sent as it to the remote server.

Specified by:
say in interface Server
Parameters:
destination - message destination.
str - message itself.

execute

public void execute(java.lang.String str)
Description copied from interface: Server
Execute the given command on the remote server.

Specified by:
execute in interface Server
Parameters:
str - the command to execute.