|
@@ -52,6 +52,8 @@ import com.dmdirc.ui.interfaces.InputWindow;
|
52
|
52
|
import com.dmdirc.ui.interfaces.ServerWindow;
|
53
|
53
|
import com.dmdirc.ui.interfaces.Window;
|
54
|
54
|
|
|
55
|
+import com.dmdirc.util.InvalidAddressException;
|
|
56
|
+import com.dmdirc.util.IrcAddress;
|
55
|
57
|
import java.io.Serializable;
|
56
|
58
|
import java.util.ArrayList;
|
57
|
59
|
import java.util.Hashtable;
|
|
@@ -152,64 +154,41 @@ public class Server extends WritableFrameContainer implements Serializable {
|
152
|
154
|
// <editor-fold defaultstate="collapsed" desc="Constructors">
|
153
|
155
|
|
154
|
156
|
/**
|
155
|
|
- * Creates a new instance of Server. Does not auto-join any channels, and
|
156
|
|
- * uses a default {@link ParserFactory}.
|
157
|
|
- *
|
158
|
|
- * @param server The hostname/ip of the server to connect to
|
159
|
|
- * @param port The port to connect to
|
160
|
|
- * @param password The server password
|
161
|
|
- * @param ssl Whether to use SSL or not
|
162
|
|
- * @param profile The profile to use
|
163
|
|
- */
|
164
|
|
- public Server(final String server, final int port, final String password,
|
165
|
|
- final boolean ssl, final Identity profile) {
|
166
|
|
- this(server, port, password, ssl, profile, new ArrayList<String>());
|
167
|
|
- }
|
168
|
|
-
|
169
|
|
- /**
|
170
|
|
- * Creates a new instance of Server. Uses a default {@link ParserFactory}.
|
|
157
|
+ * Creates a new instance of Server.
|
171
|
158
|
*
|
172
|
|
- * @param server The hostname/ip of the server to connect to
|
173
|
|
- * @param port The port to connect to
|
174
|
|
- * @param password The server password
|
175
|
|
- * @param ssl Whether to use SSL or not
|
|
159
|
+ * @since 0.6.3m2
|
|
160
|
+ * @param url The address of the server to connect to
|
176
|
161
|
* @param profile The profile to use
|
177
|
|
- * @param autochannels A list of channels to auto-join when we connect
|
|
162
|
+ * @throws InvalidAddressException If the specified URL is not valid
|
178
|
163
|
*/
|
179
|
|
- public Server(final String server, final int port, final String password,
|
180
|
|
- final boolean ssl, final Identity profile, final List<String> autochannels) {
|
181
|
|
- this(server, port, password, ssl, profile, autochannels, new ParserFactory());
|
|
164
|
+ public Server(final String url, final Identity profile) throws InvalidAddressException {
|
|
165
|
+ this(new IrcAddress(url), profile);
|
182
|
166
|
}
|
183
|
167
|
|
184
|
168
|
/**
|
185
|
|
- * Creates a new instance of Server.
|
|
169
|
+ * Creates a new server which will connect to the specified URL with
|
|
170
|
+ * the specified profile.
|
186
|
171
|
*
|
187
|
|
- * @since 0.6
|
188
|
|
- * @param server The hostname/ip of the server to connect to
|
189
|
|
- * @param port The port to connect to
|
190
|
|
- * @param password The server password
|
191
|
|
- * @param ssl Whether to use SSL or not
|
|
172
|
+ * @since 0.6.3m2
|
|
173
|
+ * @param url The address of the server to connect to
|
192
|
174
|
* @param profile The profile to use
|
193
|
|
- * @param autochannels A list of channels to auto-join when we connect
|
194
|
|
- * @param factory The {@link ParserFactory} to use to create parsers
|
195
|
175
|
*/
|
196
|
|
- public Server(final String server, final int port, final String password,
|
197
|
|
- final boolean ssl, final Identity profile,
|
198
|
|
- final List<String> autochannels, final ParserFactory factory) {
|
199
|
|
- super("server-disconnected", server, new ConfigManager("", "", server));
|
|
176
|
+ public Server(final IrcAddress url, final Identity profile) {
|
|
177
|
+ super("server-disconnected", url.getServer(),
|
|
178
|
+ new ConfigManager("", "", url.getServer()));
|
200
|
179
|
|
201
|
|
- serverInfo = new ServerInfo(server, port, password);
|
202
|
|
- serverInfo.setSSL(ssl);
|
|
180
|
+ serverInfo = new ServerInfo(url.getServer(), url.getPort(), url.getPassword());
|
|
181
|
+ serverInfo.setSSL(url.isSSL());
|
203
|
182
|
|
204
|
|
- this.autochannels = autochannels;
|
205
|
|
- this.parserFactory = factory;
|
|
183
|
+ this.autochannels = url.getChannels();
|
|
184
|
+ this.parserFactory = new ParserFactory();
|
206
|
185
|
|
207
|
186
|
window = Main.getUI().getServer(this);
|
208
|
187
|
|
209
|
188
|
ServerManager.getServerManager().registerServer(this);
|
210
|
189
|
WindowManager.addWindow(window);
|
211
|
190
|
|
212
|
|
- window.setTitle(server + ":" + port);
|
|
191
|
+ window.setTitle(url.getServer() + ":" + url.getPort());
|
213
|
192
|
|
214
|
193
|
tabCompleter.addEntries(TabCompletionType.COMMAND,
|
215
|
194
|
AliasWrapper.getAliasWrapper().getAliases());
|
|
@@ -237,7 +216,7 @@ public class Server extends WritableFrameContainer implements Serializable {
|
237
|
216
|
addRaw();
|
238
|
217
|
}
|
239
|
218
|
|
240
|
|
- connect(server, port, password, ssl, profile);
|
|
219
|
+ connect(url.getServer(), url.getPort(), url.getPassword(), url.isSSL(), profile);
|
241
|
220
|
}
|
242
|
221
|
|
243
|
222
|
// </editor-fold>
|