소스 검색

Handle channels in URLs.

This should work for most cases of irc links, but irc://irc.quakenet.org/#foo,#bar will cause URI to complain long before it gets to the parser to even attempt to handle it. (Altho the /newserver command makes it appear as "Invalid port")
Fixes Issue 3112

Change-Id: I45f38664753eaf446880f7d6c36fade0328dcca2
Reviewed-on: http://gerrit.dmdirc.com/107
Reviewed-by: Gregory Holmes <greboid@dmdirc.com>
Tested-by: Gregory Holmes <greboid@dmdirc.com>
tags/0.6.3
Shane Mc Cormack 14 년 전
부모
커밋
cb5dc5a942
2개의 변경된 파일30개의 추가작업 그리고 1개의 파일을 삭제
  1. 10
    0
      src/com/dmdirc/parser/irc/Process001.java
  2. 20
    1
      src/com/dmdirc/parser/irc/ServerInfo.java

+ 10
- 0
src/com/dmdirc/parser/irc/Process001.java 파일 보기

@@ -24,6 +24,7 @@ package com.dmdirc.parser.irc;
24 24
 
25 25
 import com.dmdirc.parser.common.ParserError;
26 26
 import com.dmdirc.parser.interfaces.callbacks.ServerReadyListener;
27
+import java.net.URI;
27 28
 
28 29
 /**
29 30
  * Process a 001 message.
@@ -68,6 +69,15 @@ public class Process001 extends IRCProcessor {
68 69
         
69 70
         callServerReady();
70 71
         myParser.startPingTimer();
72
+
73
+        final URI uri = myParser.server.getURI();
74
+        if (uri != null) {
75
+            String channelString = uri.getPath();
76
+            if (!uri.getFragment().isEmpty()) { channelString += "#" + uri.getFragment(); }
77
+            if (channelString.startsWith("/")) { channelString = channelString.substring(1); }
78
+            
79
+            myParser.joinChannel(channelString, true);
80
+        }
71 81
     }
72 82
     
73 83
     /**

+ 20
- 1
src/com/dmdirc/parser/irc/ServerInfo.java 파일 보기

@@ -57,6 +57,8 @@ public class ServerInfo {
57 57
     private String proxyUser = "";
58 58
     /** Proxy password if required. */
59 59
     private String proxyPass = "";
60
+    /** URI used to create this ServerInfo if applicable */
61
+    private URI uri = null;
60 62
     
61 63
     /** Constructor using Default values. */
62 64
     public ServerInfo () { }
@@ -82,6 +84,23 @@ public class ServerInfo {
82 84
      * @since 0.6.3
83 85
      */
84 86
     public ServerInfo(final URI uri) {
87
+        setURI(uri);
88
+    }
89
+    
90
+    /**
91
+     * Get the URI for this ServerInfo if created with one.
92
+     *
93
+     * @return URI for this ServerInfo
94
+     */
95
+    public URI getURI() { return uri; }
96
+    
97
+    /**
98
+     * Set the URI for this ServerInfo.
99
+     * This will overwrite host/port/password and isSSL.
100
+     *
101
+     * @param uri URI to use to configure this ServerInfo
102
+     */
103
+    public void setURI(final URI uri) {
85 104
         host = uri.getHost();
86 105
         port = uri.getPort();
87 106
 
@@ -91,7 +110,7 @@ public class ServerInfo {
91 110
 
92 111
         password = uri.getUserInfo() == null ? "" : uri.getUserInfo();
93 112
     }
94
-    
113
+
95 114
     /**
96 115
      * Set the hostname.
97 116
      *

Loading…
취소
저장