|
@@ -50,9 +50,7 @@ import com.dmdirc.parser.interfaces.ProtocolDescription;
|
50
|
50
|
import com.dmdirc.parser.interfaces.SecureParser;
|
51
|
51
|
import com.dmdirc.parser.interfaces.StringConverter;
|
52
|
52
|
import com.dmdirc.tls.CertificateManager;
|
53
|
|
-import com.dmdirc.ui.core.components.WindowComponent;
|
54
|
53
|
import com.dmdirc.ui.input.TabCompletionType;
|
55
|
|
-import com.dmdirc.ui.messages.BackBufferFactory;
|
56
|
54
|
import com.dmdirc.ui.messages.ColourManager;
|
57
|
55
|
import com.dmdirc.ui.messages.Formatter;
|
58
|
56
|
import com.dmdirc.ui.messages.HighlightManager;
|
|
@@ -64,7 +62,6 @@ import java.net.URI;
|
64
|
62
|
import java.net.URISyntaxException;
|
65
|
63
|
import java.net.UnknownHostException;
|
66
|
64
|
import java.util.ArrayList;
|
67
|
|
-import java.util.Arrays;
|
68
|
65
|
import java.util.Collection;
|
69
|
66
|
import java.util.Collections;
|
70
|
67
|
import java.util.Map;
|
|
@@ -166,7 +163,7 @@ public class Server implements Connection {
|
166
|
163
|
private final HighlightManager highlightManager;
|
167
|
164
|
/** Listener to use for config changes. */
|
168
|
165
|
private final ConfigChangeListener configListener = (domain, key) -> updateTitle();
|
169
|
|
- private final FrameContainer windowModel;
|
|
166
|
+ private final WindowModel windowModel;
|
170
|
167
|
/** The future used when a reconnect timer is scheduled. */
|
171
|
168
|
private ScheduledFuture<?> reconnectTimerFuture;
|
172
|
169
|
|
|
@@ -174,28 +171,19 @@ public class Server implements Connection {
|
174
|
171
|
* Creates a new server which will connect to the specified URL with the specified profile.
|
175
|
172
|
*/
|
176
|
173
|
public Server(
|
|
174
|
+ final WindowModel windowModel,
|
177
|
175
|
final ConfigProviderMigrator configMigrator,
|
178
|
176
|
final ParserFactory parserFactory,
|
179
|
177
|
final IdentityFactory identityFactory,
|
180
|
178
|
final QueryFactory queryFactory,
|
181
|
|
- final DMDircMBassador eventBus,
|
182
|
179
|
final MessageEncoderFactory messageEncoderFactory,
|
183
|
180
|
final ConfigProvider userSettings,
|
184
|
181
|
final GroupChatManagerImplFactory groupChatManagerFactory,
|
185
|
182
|
final ScheduledExecutorService executorService,
|
186
|
183
|
@Nonnull final URI uri,
|
187
|
184
|
@Nonnull final Profile profile,
|
188
|
|
- final BackBufferFactory backBufferFactory,
|
189
|
185
|
final UserManager userManager) {
|
190
|
|
- // TODO: Pass this in
|
191
|
|
- windowModel =
|
192
|
|
- new FrameContainer("server-disconnected", getHost(uri), getHost(uri),
|
193
|
|
- configMigrator.getConfigProvider(), backBufferFactory, eventBus,
|
194
|
|
- Arrays.asList(WindowComponent.TEXTAREA.getIdentifier(),
|
195
|
|
- WindowComponent.INPUTFIELD.getIdentifier(),
|
196
|
|
- WindowComponent.CERTIFICATE_VIEWER.getIdentifier()));
|
197
|
|
- windowModel.setConnection(this);
|
198
|
|
-
|
|
186
|
+ this.windowModel = windowModel;
|
199
|
187
|
this.parserFactory = parserFactory;
|
200
|
188
|
this.identityFactory = identityFactory;
|
201
|
189
|
this.configMigrator = configMigrator;
|
|
@@ -219,7 +207,6 @@ public class Server implements Connection {
|
219
|
207
|
windowModel.getConfigManager().addChangeListener("formatter", "serverName", configListener);
|
220
|
208
|
windowModel.getConfigManager().addChangeListener("formatter", "serverTitle", configListener);
|
221
|
209
|
|
222
|
|
- windowModel.initBackBuffer();
|
223
|
210
|
this.highlightManager = new HighlightManager(windowModel.getConfigManager(),
|
224
|
211
|
new ColourManager(windowModel.getConfigManager()));
|
225
|
212
|
highlightManager.init();
|
|
@@ -527,26 +514,6 @@ public class Server implements Connection {
|
527
|
514
|
new ArrayList<>(queries.values()).forEach(Query::close);
|
528
|
515
|
}
|
529
|
516
|
|
530
|
|
- /**
|
531
|
|
- * Retrieves the host component of the specified URI, or throws a relevant exception if this is
|
532
|
|
- * not possible.
|
533
|
|
- *
|
534
|
|
- * @param uri The URI to be processed
|
535
|
|
- *
|
536
|
|
- * @return The URI's host component, as returned by {@link URI#getHost()}.
|
537
|
|
- *
|
538
|
|
- * @throws NullPointerException If <code>uri</code> is null
|
539
|
|
- * @throws IllegalArgumentException If the specified URI has no host
|
540
|
|
- * @since 0.6.4
|
541
|
|
- */
|
542
|
|
- private static String getHost(final URI uri) {
|
543
|
|
- if (uri.getHost() == null) {
|
544
|
|
- throw new IllegalArgumentException("URIs must have hosts");
|
545
|
|
- }
|
546
|
|
-
|
547
|
|
- return uri.getHost();
|
548
|
|
- }
|
549
|
|
-
|
550
|
517
|
/**
|
551
|
518
|
* Builds an appropriately configured {@link Parser} for this server.
|
552
|
519
|
*
|