/*
* Copyright (c) 2006-2017 DMDirc Developers
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.dmdirc.parser.interfaces;
import com.dmdirc.parser.common.CallbackManager;
import com.dmdirc.parser.common.ChannelJoinRequest;
import com.dmdirc.parser.common.CompositionState;
import com.dmdirc.parser.common.IgnoreList;
import com.dmdirc.parser.common.QueuePriority;
import java.net.URI;
import java.util.Collection;
import java.util.List;
/**
* A parser connects to a back-end chat system and handles all communication
* with it.
*
* @since 0.6.3m2
* @author chris
*/
public interface Parser {
/**
* Connect to server.
*/
void connect();
/**
* Disconnect from server. This method will quit and automatically close the
* socket without waiting for the server.
*
* @param message Reason for quitting.
*/
void disconnect(String message);
/**
*
* Disconnect from server. This method will wait for the server to
* close the socket.
*
* @param message Reason for quitting.
*/
void quit(String message);
/**
* Join a channel with no key.
*
* @param channel Name of channel to join
*/
void joinChannel(String channel);
/**
* Joins a channel with the specified key.
*
* @param channel Name of channel to join
* @param key The key required to join the channel
*/
void joinChannel(String channel, String key);
/**
* Joins the specified channels.
*
* @since 0.6.4
* @param channels The channels to be joined
*/
void joinChannels(ChannelJoinRequest ... channels);
/**
* Retrieves a channel information object for the specified channel.
*
* @param channel Name of the channel to retrieve an information object for
* @return A corresponding channel info object
*/
ChannelInfo getChannel(String channel);
/**
* Retrieves a collection of all known channels.
*
* @return A collection of known channels
*/
Collection extends ChannelInfo> getChannels();
/**
* Get the IP address that this parser will bind to.
*
* @return IP that this parser is bound to ("" for default IP)
*/
String getBindIP();
/**
* Set the IP address that this parser will bind to.
*
* @param ip IP to bind to
*/
void setBindIP(String ip);
/**
* Get the IPv6 address that this parser will bind to.
*
* @return IPv6 that this parser is bound to ("" for default IP)
*/
String getBindIPv6();
/**
* Set the IPv6 address that this parser will bind to.
*
* @param ip IPv6 IP to bind to
*/
void setBindIPv6(String ip);
/**
* Gets the proxy URI that this parser will use.
*
* @return A URI representing the proxy this parser is configured to use,
* or null
if no proxy is set.
* @since 0.6.7
* @see #setProxy(java.net.URI)
*/
URI getProxy();
/**
* Configures the proxy that this parser will use. The URI should consist
* of the following components:
*
socks://user:pass@dmdirc.com:123/
.
*
* @param proxy A URI representing the proxy this parser should use,
* or null
to connect directly.
* @since 0.6.7
* @see #getProxy()
*/
void setProxy(URI proxy);
/**
* Determines the maximimum length a message of the specified type may be.
*
* @param type Type of message (eg PRIVMSG)
* @param target Target of message (eg channel name)
* @return The maximum length of the message
*/
int getMaxLength(String type, String target);
/**
* Determines the maximum length any message/raw command may be.
*
* @return The maximum length of a message
*/
int getMaxLength();
/**
* Returns a {@link ClientInfo} object which represents the locally
* connected client.
*
* @return An info object for the local client
*/
LocalClientInfo getLocalClient();
/**
* Retrieves a {@link ClientInfo} object which corresponds to the specified
* details. If the client wasn't previously known, it will be created.
*
* @param details The details of the client to look up
* @return A corresponding client info object
*/
ClientInfo getClient(String details);
/**
* Sends a raw message directly to the backend system. The message will
* need to be of the appropriate format for whatever system is in use.
*
* @param message The message to be sent
*/
void sendRawMessage(String message);
/**
* Sends a raw message directly to the backend system. The message will
* need to be of the appropriate format for whatever system is in use.
*
* @param message The message to be sent
* @param priority Priority of this line. (Priorities are advisory and not
* guaranteed to be enforced.
*/
void sendRawMessage(String message, QueuePriority priority);
/**
* Retrieves an object that can be used to convert between upper- and lower-
* case strings in the relevant charset for the backend system.
*
* @return A string convertor for this parser
*/
StringConverter getStringConverter();
/**
* Determines whether the specified channel name is valid or not for this
* parser.
*
* @param name The name of the channel to be tested
* @return True if the channel name is valid, false otherwise
*/
boolean isValidChannelName(String name);
/**
* Get a URI that shows where this parser is connected to.
*
* @return URI that shows where this parser is connected to.
* @since 0.6.3
*/
URI getURI();
/**
* Compare the given URI to the URI we are currently using to see if they
* would both result in the parser connecting to the same place, even if the
* URIs do not match exactly.
*
* @param uri URI to compare with the Parsers own URI.
* @return True if the Given URI is the "same" as the one we are using.
* @since 0.6.3
*/
boolean compareURI(final URI uri);
/**
* Extracts any channels present in the specified URI.
*
* @param uri The URI to extract channels from
* @return A list of channel join requests extracted from the specified URI
* @since 0.6.4
*/
Collection extends ChannelJoinRequest> extractChannels(final URI uri);
/**
* Retrieves the name of the server that this parser is, or has been,
* connected to.
*
* @return This parser's server's name
*/
String getServerName();
/**
* Retrieves the name of the network that this parser is connected to.
*
* @return This parser's network's name
*/
String getNetworkName();
/**
* Retrieves a textual description of the software running on the server.
*
* @return This parser's server's software name
*/
String getServerSoftware();
/**
* Retrieves the detected type of the software running on the server.
*
* @return This parser's server's software type
*/
String getServerSoftwareType();
/**
* Get the list of lines that lines that help describe the server.
*
* @return List of identification lines for the server.
*
* @since 0.6.4,
*/
List(ping timer interval) * (ping timer fraction)
millisecs.
*
* For example, setting the interval to 10,000 (10 seconds) and the fraction
* to 6 means that pings will be sent once every minute and if a reply is
* not received within 10 seconds, a ping failed event will be raised.
*
* @param newValue The new value of the ping timer fraction
*/
void setPingTimerFraction(int newValue);
/**
* Retrieves the number of ping timer intervals that must pass before this
* parser sends a ping request.
*
* @return This parser's ping timer fraction
*/
int getPingTimerFraction();
/**
* Sets the local user's composition state for a conversation with the
* specified host.
*
* @param host The host of the user who the conversation is with
* @param state The new composition state
*/
void setCompositionState(String host, CompositionState state);
/**
* Requests a list of all known groups from the server.
*
* @param searchTerms The search terms to pass to the server, or an empty
* string for no terms.
*/
void requestGroupList(String searchTerms);
}