[dmdirc commit] r5818 - in trunk/modules/parser/src/com/dmdirc/parser: interfaces irc

1 view
Skip to first unread message

com...@dmdirc.com

unread,
Jan 23, 2010, 3:44:23 PM1/23/10
to dmd...@googlegroups.com
Author: git
Date: 2010-01-23 20:44:21 +0000 (Sat, 23 Jan 2010)
New Revision: 5818

Modified:
trunk/modules/parser/src/com/dmdirc/parser/interfaces/Parser.java
trunk/modules/parser/src/com/dmdirc/parser/irc/IRCParser.java
trunk/modules/parser/src/com/dmdirc/parser/irc/Process001.java
trunk/modules/parser/src/com/dmdirc/parser/irc/ServerInfo.java
Log:
Update submodules: parser, plugins

Git-version: 0.6.3m2-345-g1f4bdef


Modified: trunk/modules/parser/src/com/dmdirc/parser/interfaces/Parser.java
===================================================================
--- trunk/modules/parser/src/com/dmdirc/parser/interfaces/Parser.java 2010-01-23 20:44:03 UTC (rev 5817)
+++ trunk/modules/parser/src/com/dmdirc/parser/interfaces/Parser.java 2010-01-23 20:44:21 UTC (rev 5818)
@@ -186,6 +186,25 @@
*/
boolean compareURI(final URI uri);

+ /**
+ * Updates this parser with a new URI. The new URI should be fundamentally
+ * the same as the one the parser connected to (to the extent that
+ * {@link #compareURI(java.net.URI)} returns true), but it may contain
+ * extra information (such as an additional list of channels to join).
+ * This operation should be non-destructive; that is, if the URI provided
+ * contains less information than a previous URI, the 'missing' information
+ * should not be treated as an instruction to remove it.
+ * <p>
+ * For example, if the parser was originally constructed with a URI
+ * <code>irc://irc.quakenet.org/chan1,chan2</code>, and this method was
+ * subsequently called with an argument of
+ * <code>irc://irc.quakenet.org/chan3</code>, the IRC parser should join
+ * the channel "chan3" and would also remain in chan1 and chan2.
+ *
+ * @param uri The URI to update this parser with
+ * @since 0.6.3
+ */
+ void updateURI(final URI uri);

/**
* Retrieves the name of the server that this parser is connected to.
@@ -286,7 +305,7 @@

/**
* Retrieves a list of channel user modes, in descending priority order.
- *
+ *
* @return A string containing a list of channel user mode characters
*/
String getChannelUserModes();
@@ -298,11 +317,11 @@
* @since 0.6.3
*/
String getChannelPrefixes();
-
+
/**
* Retrieves the object which is responsible for managing callbacks for
* this parser.
- *
+ *
* @return This parser's callback manager
*/
CallbackManager<? extends Parser> getCallbackManager();

Modified: trunk/modules/parser/src/com/dmdirc/parser/irc/IRCParser.java
===================================================================
--- trunk/modules/parser/src/com/dmdirc/parser/irc/IRCParser.java 2010-01-23 20:44:03 UTC (rev 5817)
+++ trunk/modules/parser/src/com/dmdirc/parser/irc/IRCParser.java 2010-01-23 20:44:21 UTC (rev 5818)
@@ -269,7 +269,7 @@

/** This is the IP we want to bind to. */
private String bindIP = "";
-
+
/** This is list containing 001 - 005 inclusive. */
private final List<String> serverInformationLines = new LinkedList<String>();

@@ -352,6 +352,14 @@
newURI.getPort() == oldURI.getPort();
}

+ /** {@inheritDoc} */
+ @Override
+ public void updateURI(final URI uri) {
+ final String channels = new ServerInfo(uri).getChannels();
+ if (channels != null) {
+ joinChannel(channels, true);
+ }
+ }

/** {@inheritDoc} */
@Override
@@ -598,7 +606,7 @@
protected synchronized boolean callPost005() {
if (post005) { return false; }
post005 = true;
-
+
if (!h005Info.containsKey("CHANTYPES")) { parseChanPrefix(); }
if (!h005Info.containsKey("PREFIX")) { parsePrefixModes(); }
if (!h005Info.containsKey("USERMODES")) { parseUserModes(); }
@@ -800,7 +808,7 @@
final ParserError ei = new ParserError(ParserError.ERROR_ERROR + (isUserError ? ParserError.ERROR_USER : 0), "Exception with server socket", getLastLine());
ei.setException(e);
callConnectError(ei);
-
+
if (currentSocketState != SocketState.CLOSED) {
currentSocketState = SocketState.CLOSED;
callSocketClosed();
@@ -851,7 +859,7 @@
}
} catch (IOException e) {
callDebugInfo(DEBUG_SOCKET, "Exception in main loop (" + e.getMessage() + "), Aborted");
-
+
if (currentSocketState != SocketState.CLOSED) {
currentSocketState = SocketState.CLOSED;
callSocketClosed();
@@ -1009,7 +1017,7 @@
}
}
}
-
+
return true;
}

@@ -1030,7 +1038,7 @@
public String getLastLine() {
return lastLine;
}
-
+
/**
* Get the list of lines the server gave from 001 - 005.
*
@@ -1112,7 +1120,7 @@
// Some networks may send a NICK message if you nick change before 001
// Eat it up so that it isn't treated as a notice auth.
if (token[1].equalsIgnoreCase("NICK")) { break; }
-
+
// Otherwise, send to Notice Auth
try { myProcessingManager.process("Notice Auth", token); } catch (ProcessorNotFoundException e) { }
break;
@@ -1310,7 +1318,7 @@
if (chanPrefix.isEmpty()) {
return "#&";
}
-
+
final StringBuilder builder = new StringBuilder(chanPrefix.size());

for (Character prefix : chanPrefix) {
@@ -1575,7 +1583,7 @@
} else {
me.setNickname(nickname);
}
-
+
thinkNickname = nickname;
}

@@ -1712,7 +1720,7 @@
sendString("QUIT :" + reason);
}
}
-
+
/** {@inheritDoc} */
@Override
public void disconnect(final String message) {
@@ -1877,7 +1885,7 @@

pingTimerSem.release();
}
-
+
/**
* Stop the pingTimer.
*/
@@ -1906,18 +1914,18 @@
pingTimer.cancel();
}
pingTimerSem.release();
-
+
return;
}
if (getPingNeeded()) {
if (!callPingFailed()) {
pingTimerSem.acquireUninterruptibly();
-
+
if (pingTimer != null && pingTimer.equals(timer)) {
pingTimer.cancel();
}
pingTimerSem.release();
-
+
disconnect("Server not responding.");
}
} else {

Modified: trunk/modules/parser/src/com/dmdirc/parser/irc/Process001.java
===================================================================
--- trunk/modules/parser/src/com/dmdirc/parser/irc/Process001.java 2010-01-23 20:44:03 UTC (rev 5817)
+++ trunk/modules/parser/src/com/dmdirc/parser/irc/Process001.java 2010-01-23 20:44:21 UTC (rev 5818)
@@ -24,7 +24,6 @@

import com.dmdirc.parser.common.ParserError;
import com.dmdirc.parser.interfaces.callbacks.ServerReadyListener;
-import java.net.URI;

/**
* Process a 001 message.
@@ -42,7 +41,7 @@
// << :demon1.uk.quakenet.org 001 Java-Test :Welcome to the QuakeNet IRC Network, Java-Test
myParser.serverName = token[0].substring(1,token[0].length());
final String sNick = token[2];
-
+
// myself will be fake if we havn't recieved a 001 yet
if (myParser.getLocalClient().isFake()) {
// Update stored information
@@ -66,31 +65,26 @@
}
}
}
-
+
callServerReady();
myParser.startPingTimer();

- final URI uri = myParser.server.getURI();
- if (uri != null) {
- String channelString = uri.getPath();
- if (uri.getRawQuery() != null && !uri.getRawQuery().isEmpty()) { channelString += "?" + uri.getRawQuery(); }
- if (uri.getRawFragment() != null && !uri.getRawFragment().isEmpty()) { channelString += "#" + uri.getRawFragment(); }
- if (channelString.startsWith("/")) { channelString = channelString.substring(1); }
-
- myParser.joinChannel(channelString, true);
+ final String channels = myParser.server.getChannels();
+ if (channels != null) {
+ myParser.joinChannel(channels, true);
}
}
-
+
/**
* Callback to all objects implementing the ServerReady Callback.
*
* @see IServerReady
* @return true if a method was called, false otherwise
- */
+ */
protected boolean callServerReady() {
return getCallbackManager().getCallbackType(ServerReadyListener.class).call();
}
-
+
/**
* What does this IRCProcessor handle.
*
@@ -99,8 +93,8 @@
@Override
public String[] handles() {
return new String[]{"001"};
- }
-
+ }
+
/**
* Create a new instance of the IRCProcessor Object.
*

Modified: trunk/modules/parser/src/com/dmdirc/parser/irc/ServerInfo.java
===================================================================
--- trunk/modules/parser/src/com/dmdirc/parser/irc/ServerInfo.java 2010-01-23 20:44:03 UTC (rev 5817)
+++ trunk/modules/parser/src/com/dmdirc/parser/irc/ServerInfo.java 2010-01-23 20:44:21 UTC (rev 5818)
@@ -27,7 +27,7 @@

/**
* Contains Server information.
- *
+ *
* @author Shane Mc Cormack
* @author Chris Smith
* @see IRCParser
@@ -47,7 +47,7 @@
/** Optional password needed to connect to server (Default: ""). */
private String password = "";
/** Is this an ssl-enabled server (Default: false). */
- private boolean isSSL = false;
+ private boolean isSSL = false;
/** Are we using a socks proxy (Default: false). */
private boolean useSocksProxy = false;
/** Proxy server to connect to (Default: "127.0.0.1"). */
@@ -60,10 +60,10 @@
private String proxyPass = "";
/** URI used to create this ServerInfo if applicable */
private URI uri = null;
-
+
/** Constructor using Default values. */
public ServerInfo () { }
-
+
/**
* Constructor using specifed host, port and password, SSL/Proxy must be specifed separately.
*
@@ -87,7 +87,7 @@
public ServerInfo(final URI uri) {
setURI(uri);
}
-
+
/**
* Get the URI for this ServerInfo.
* This will return a new URI based on this ServerInfo.
@@ -134,7 +134,7 @@
}
}
}
-
+
/**
* Set the URI for this ServerInfo.
* This will overwrite host/port/password and isSSL.
@@ -159,91 +159,91 @@
* @param newValue Value to set to.
*/
public void setHost(final String newValue) { host = newValue; }
-
+
/**
* Get the hostname.
*
* @return Current hostname
*/
public String getHost() { return host; }
-
+
/**
* Set the port.
*
* @param newValue Value to set to.
*/
public void setPort(final int newValue) { port = newValue; }
-
+
/**
* Get the port.
*
* @return Current port
*/
public int getPort() { return port; }
-
+
/**
* Set the password.
*
* @param newValue Value to set to.
*/
public void setPassword(final String newValue) { password = newValue; }
-
+
/**
* Get the password.
*
* @return Current Password
*/
public String getPassword() { return password; }
-
+
/**
* Set if the server uses ssl.
*
* @param newValue true if server uses ssl, else false
*/
public void setSSL(final boolean newValue) { isSSL = newValue; }
-
+
/**
* Get if the server uses ssl.
*
* @return true if server uses ssl, else false
*/
public boolean getSSL() { return isSSL; }
-
+
/**
* Set if we are connecting via a socks proxy.
*
* @param newValue true if we are using socks, else false
*/
public void setUseSocks(final boolean newValue) { useSocksProxy = newValue; }
-
+
/**
* Get if we are connecting via a socks proxy.
*
* @return true if we are using socks, else false
*/
public boolean getUseSocks() { return useSocksProxy; }
-
+
/**
* Set the Proxy hostname.
*
* @param newValue Value to set to.
*/
public void setProxyHost(final String newValue) { proxyHost = newValue; }
-
+
/**
* Get the Proxy hostname.
*
* @return Current Proxy hostname
*/
public String getProxyHost() { return proxyHost; }
-
+
/**
* Set the Proxy port.
*
* @param newValue Value to set to.
*/
public void setProxyPort(final int newValue) { proxyPort = newValue; }
-
+
/**
* Get the Proxy port.
*
@@ -257,26 +257,46 @@
* @param newValue Value to set to.
*/
public void setProxyUser(final String newValue) { proxyUser = newValue; }
-
+
/**
* Get the Proxy username.
*
* @return Current Proxy username
*/
public String getProxyUser() { return proxyUser; }
-
+
/**
* Set the Proxy password.
*
* @param newValue Value to set to.
*/
public void setProxyPass(final String newValue) { proxyPass = newValue; }
-
+
/**
* Get the Proxy password.
*
* @return Current Proxy password
*/
public String getProxyPass() { return proxyPass; }
+
+ /**
+ * Retrieves a String describing any channels included in this ServerInfo's
+ * URI.
+ *
+ * @return A channel string for this URI, or null if no URI specified
+ * @since 0.6.3
+ */
+ public String getChannels() {
+ if (uri == null) {
+ return null;
+ }
+
+ String channelString = uri.getPath();
+ if (uri.getRawQuery() != null && !uri.getRawQuery().isEmpty()) { channelString += "?" + uri.getRawQuery(); }
+ if (uri.getRawFragment() != null && !uri.getRawFragment().isEmpty()) { channelString += "#" + uri.getRawFragment(); }
+ if (channelString.startsWith("/")) { channelString = channelString.substring(1); }
+
+ return channelString;
+ }
}

Reply all
Reply to author
Forward
0 new messages