|
@@ -51,9 +51,9 @@ import com.dmdirc.ui.input.TabCompletionType;
|
51
|
51
|
import com.dmdirc.ui.interfaces.InputWindow;
|
52
|
52
|
import com.dmdirc.ui.interfaces.ServerWindow;
|
53
|
53
|
import com.dmdirc.ui.interfaces.Window;
|
54
|
|
-
|
55
|
54
|
import com.dmdirc.util.InvalidAddressException;
|
56
|
55
|
import com.dmdirc.util.IrcAddress;
|
|
56
|
+
|
57
|
57
|
import java.io.Serializable;
|
58
|
58
|
import java.util.ArrayList;
|
59
|
59
|
import java.util.Hashtable;
|
|
@@ -97,20 +97,24 @@ public class Server extends WritableFrameContainer implements Serializable {
|
97
|
97
|
|
98
|
98
|
/** Open channels that currently exist on the server. */
|
99
|
99
|
private final Map<String, Channel> channels = new Hashtable<String, Channel>();
|
|
100
|
+
|
100
|
101
|
/** Open query windows on the server. */
|
101
|
102
|
private final List<Query> queries = new ArrayList<Query>();
|
102
|
103
|
|
103
|
104
|
/** The Parser instance handling this server. */
|
104
|
105
|
private transient Parser parser;
|
|
106
|
+
|
105
|
107
|
/** The IRC Parser Thread. */
|
106
|
108
|
private transient Thread parserThread;
|
|
109
|
+
|
107
|
110
|
/** The raw frame used for this server instance. */
|
108
|
111
|
private Raw raw;
|
|
112
|
+
|
109
|
113
|
/** The ServerWindow corresponding to this server. */
|
110
|
114
|
private ServerWindow window;
|
111
|
115
|
|
112
|
|
- /** The details of the server we're connecting to. */
|
113
|
|
- private ServerInfo serverInfo;
|
|
116
|
+ /** The address of the server we're connecting to. */
|
|
117
|
+ private IrcAddress address;
|
114
|
118
|
|
115
|
119
|
/** The profile we're using. */
|
116
|
120
|
private transient Identity profile;
|
|
@@ -121,9 +125,6 @@ public class Server extends WritableFrameContainer implements Serializable {
|
121
|
125
|
/** The timer we're using to delay reconnects. */
|
122
|
126
|
private Timer reconnectTimer;
|
123
|
127
|
|
124
|
|
- /** Channels we're meant to auto-join. */
|
125
|
|
- private final List<String> autochannels;
|
126
|
|
-
|
127
|
128
|
/** The tabcompleter used for this server. */
|
128
|
129
|
private final TabCompleter tabCompleter = new TabCompleter();
|
129
|
130
|
/** The last activated internal frame for this server. */
|
|
@@ -144,9 +145,6 @@ public class Server extends WritableFrameContainer implements Serializable {
|
144
|
145
|
/** Our string convertor. */
|
145
|
146
|
private StringConverter converter = new IRCStringConverter();
|
146
|
147
|
|
147
|
|
- /** The parser factory to use. */
|
148
|
|
- private final ParserFactory parserFactory;
|
149
|
|
-
|
150
|
148
|
// </editor-fold>
|
151
|
149
|
|
152
|
150
|
// </editor-fold>
|
|
@@ -177,11 +175,7 @@ public class Server extends WritableFrameContainer implements Serializable {
|
177
|
175
|
super("server-disconnected", url.getServer(),
|
178
|
176
|
new ConfigManager("", "", url.getServer()));
|
179
|
177
|
|
180
|
|
- serverInfo = new ServerInfo(url.getServer(), url.getPort(), url.getPassword());
|
181
|
|
- serverInfo.setSSL(url.isSSL());
|
182
|
|
-
|
183
|
|
- this.autochannels = url.getChannels();
|
184
|
|
- this.parserFactory = new ParserFactory();
|
|
178
|
+ this.address = url;
|
185
|
179
|
|
186
|
180
|
window = Main.getUI().getServer(this);
|
187
|
181
|
|
|
@@ -216,7 +210,7 @@ public class Server extends WritableFrameContainer implements Serializable {
|
216
|
210
|
addRaw();
|
217
|
211
|
}
|
218
|
212
|
|
219
|
|
- connect(url.getServer(), url.getPort(), url.getPassword(), url.isSSL(), profile);
|
|
213
|
+ connect(url, profile);
|
220
|
214
|
}
|
221
|
215
|
|
222
|
216
|
// </editor-fold>
|
|
@@ -226,19 +220,16 @@ public class Server extends WritableFrameContainer implements Serializable {
|
226
|
220
|
/**
|
227
|
221
|
* Connects to a new server with the specified details.
|
228
|
222
|
*
|
229
|
|
- * @param server The hostname/ip of the server to connect to
|
230
|
|
- * @param port The port to connect to
|
231
|
|
- * @param password The server password
|
232
|
|
- * @param ssl Whether to use SSL or not
|
|
223
|
+ * @param address The address of the server to connect to
|
233
|
224
|
* @param profile The profile to use
|
|
225
|
+ * @since 0.6.3m2
|
234
|
226
|
*/
|
235
|
227
|
@Precondition({
|
236
|
|
- "The IRC Parser is null or not connected",
|
|
228
|
+ "The current parser is null or not connected",
|
237
|
229
|
"The specified profile is not null"
|
238
|
230
|
})
|
239
|
231
|
@SuppressWarnings("fallthrough")
|
240
|
|
- public void connect(final String server, final int port, final String password,
|
241
|
|
- final boolean ssl, final Identity profile) {
|
|
232
|
+ public void connect(final IrcAddress address, final Identity profile) {
|
242
|
233
|
assert profile != null;
|
243
|
234
|
|
244
|
235
|
synchronized (myState) {
|
|
@@ -271,19 +262,19 @@ public class Server extends WritableFrameContainer implements Serializable {
|
271
|
262
|
+ "is still connected.\n\nMy state:" + getState());
|
272
|
263
|
}
|
273
|
264
|
|
274
|
|
- if (!server.equals(getName())) {
|
275
|
|
- setName(server);
|
|
265
|
+ // Update the name of this container (shown in treeview, etc)
|
|
266
|
+ if (!address.getServer().equals(getName())) {
|
|
267
|
+ setName(address.getServer());
|
276
|
268
|
}
|
277
|
269
|
|
278
|
|
- getConfigManager().migrate("", "", server);
|
279
|
|
-
|
280
|
|
- serverInfo = buildServerInfo(server, port, password, ssl);
|
|
270
|
+ getConfigManager().migrate("", "", address.getServer());
|
281
|
271
|
|
|
272
|
+ this.address = address;
|
282
|
273
|
this.profile = profile;
|
283
|
274
|
|
284
|
275
|
updateIcon();
|
285
|
276
|
|
286
|
|
- addLine("serverConnecting", server, port);
|
|
277
|
+ addLine("serverConnecting", address.getServer(), address.getPort());
|
287
|
278
|
|
288
|
279
|
parser = buildParser();
|
289
|
280
|
|
|
@@ -319,8 +310,7 @@ public class Server extends WritableFrameContainer implements Serializable {
|
319
|
310
|
|
320
|
311
|
disconnect(reason);
|
321
|
312
|
|
322
|
|
- connect(serverInfo.getHost(), serverInfo.getPort(),
|
323
|
|
- serverInfo.getPassword(), serverInfo.getSSL(), profile);
|
|
313
|
+ connect(address, profile);
|
324
|
314
|
}
|
325
|
315
|
}
|
326
|
316
|
|
|
@@ -712,11 +702,11 @@ public class Server extends WritableFrameContainer implements Serializable {
|
712
|
702
|
* @return A configured IRC parser.
|
713
|
703
|
*/
|
714
|
704
|
private Parser buildParser() {
|
715
|
|
- final CertificateManager certManager = new CertificateManager(serverInfo.getHost(),
|
|
705
|
+ final CertificateManager certManager = new CertificateManager(address.getServer(),
|
716
|
706
|
getConfigManager());
|
717
|
707
|
|
718
|
708
|
final MyInfo myInfo = buildMyInfo();
|
719
|
|
- final Parser myParser = parserFactory.getParser(myInfo, serverInfo);
|
|
709
|
+ final Parser myParser = new ParserFactory().getParser(myInfo, address);
|
720
|
710
|
|
721
|
711
|
if (myParser instanceof SecureParser) {
|
722
|
712
|
final SecureParser secureParser = (SecureParser) myParser;
|
|
@@ -766,7 +756,7 @@ public class Server extends WritableFrameContainer implements Serializable {
|
766
|
756
|
*/
|
767
|
757
|
private void updateIcon() {
|
768
|
758
|
final String icon = myState.getState() == ServerState.CONNECTED
|
769
|
|
- ? serverInfo.getSSL() ? "secure-server" : "server"
|
|
759
|
+ ? address.isSSL() ? "secure-server" : "server"
|
770
|
760
|
: "server-disconnected";
|
771
|
761
|
setIcon(icon);
|
772
|
762
|
}
|
|
@@ -804,7 +794,7 @@ public class Server extends WritableFrameContainer implements Serializable {
|
804
|
794
|
parser.joinChannel(channel);
|
805
|
795
|
}
|
806
|
796
|
} else {
|
807
|
|
- autochannels.add(channel);
|
|
797
|
+ address.getChannels().add(channel);
|
808
|
798
|
}
|
809
|
799
|
}
|
810
|
800
|
}
|
|
@@ -1354,7 +1344,7 @@ public class Server extends WritableFrameContainer implements Serializable {
|
1354
|
1344
|
}
|
1355
|
1345
|
}
|
1356
|
1346
|
|
1357
|
|
- for (String channel : autochannels) {
|
|
1347
|
+ for (String channel : address.getChannels()) {
|
1358
|
1348
|
parser.joinChannel(channel);
|
1359
|
1349
|
}
|
1360
|
1350
|
|