Browse Source

Fixes issue 3231.

Change-Id: I2f9078caa4eec957d5bdda310b619916b4132293
Reviewed-on: http://gerrit.dmdirc.com/144
Reviewed-by: Gregory Holmes <greboid@dmdirc.com>
Tested-by: Gregory Holmes <greboid@dmdirc.com>
tags/0.6.3
Shane Mc Cormack 14 years ago
parent
commit
8d876698e5

+ 12
- 0
src/com/dmdirc/parser/interfaces/Parser.java View File

@@ -171,9 +171,21 @@ public interface Parser extends Runnable {
171 171
      * Get a URI that shows where this parser is connected to.
172 172
      *
173 173
      * @return URI that shows where this parser is connected to.
174
+     * @since 0.6.4
174 175
      */
175 176
     URI getURI();
176 177
 
178
+    /**
179
+     * Compare the given URI to the URI we are currently using to see if they
180
+     * would both result in the parser connecting to the same place, even if the
181
+     * URIs do not match exactly.
182
+     *
183
+     * @param uri URI to compare with the Parsers own URI.
184
+     * @return True if the Given URI is the "same" as the one we are using.
185
+     * @since 0.6.4
186
+     */
187
+    boolean compareURI(final URI uri);
188
+
177 189
 
178 190
     /**
179 191
      * Retrieves the name of the server that this parser is connected to.

+ 18
- 0
src/com/dmdirc/parser/irc/IRCParser.java View File

@@ -338,6 +338,24 @@ public class IRCParser implements SecureParser, Runnable {
338 338
     @Override
339 339
     public URI getURI() { return server.getURI(); }
340 340
 
341
+    /** {@inheritDoc} */
342
+    @Override
343
+    public boolean compareURI(final URI uri) {
344
+        // Parse the given URI to set any defaults.
345
+        final ServerInfo si = new ServerInfo(uri);
346
+        final URI newURI = si.getURI();
347
+        // Get the old URI.
348
+        final URI oldURI = server.getURI();
349
+
350
+        // Check that protocol, host and port are the same.
351
+        // Anything else won't change the server we connect to just what we
352
+        // would do after connecting, so is not relevent.
353
+        return newURI.getScheme().equalsIgnoreCase(oldURI.getScheme()) &&
354
+               newURI.getHost().equalsIgnoreCase(oldURI.getHost()) &&
355
+               newURI.getPort() == oldURI.getPort();
356
+    }
357
+
358
+
341 359
     /** {@inheritDoc} */
342 360
     @Override
343 361
     public Map<Object, Object> getMap() { return myMap; }

Loading…
Cancel
Save